bumptech / palm

Protobufs Are Lightweight Messages

Home Page:http://bu.mp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow setting repeated fields via __init__

schmichael opened this issue · 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