Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Allow setting repeated fields via __init__ #10

Open
schmichael opened this issue May 3, 2012 · 0 comments
Open

Allow setting repeated fields via __init__ #10

schmichael opened this issue May 3, 2012 · 0 comments

Comments

@schmichael
Copy link
Contributor

The proto file t.proto:

message M {
  repeated string a = 0;
}

It'd be nice to be able to set the a field from a list during initialization like: pb = M(a=["one", "two"])

Google's protobuf library allows this, but palm does not:

>>> import t_palm
>>> pb = t_palm.M(a=['a', 'b'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "t_palm.py", line 14, in __init__
    ProtoBase.__init__(self, _pbf_buf, **kw)
  File "palm.pyx", line 154, in palm.palm.ProtoBase.__init__ (palm/palm.c:1583)
  File "t_palm.py", line 70, in _set_a
    raise ProtoValueError(list_assign_error)
palm.palm.ProtoValueError: Can't assign list to repeated field a
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant