palm icon indicating copy to clipboard operation
palm copied to clipboard

Allow setting repeated fields via __init__

Open schmichael opened this issue 12 years ago • 0 comments

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

schmichael avatar May 03 '12 23:05 schmichael