Assignment of item at index in repeated field
See original GitHub issueWith a normal Python list we can do:
l = [1, 2, 3, 4, 5]
l[1] = 'hello'
print(l)
> [1, 'hello', 3, 4, 5]
However for a repeated field of a message wrapped by proto-plus we see slightly different behavior:
l = [1, 2, 3, 4, 5]
l[1] = 'hello'
print(l)
> [1, 'hello', 2, 3, 4, 5]
Notice how the 2
just gets push back an index instead of overridden.
For a raw protobuf message, we would normally do:
l = [1, 2, 3, 4, 5]
l[1].CopyFrom('hello')
print(l)
> [1, 'hello', 3, 4, 5]
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to assign to repeated field? - python - Stack Overflow
I get an error: Assigment not allowed for repeated field "id" in protocol message object How to assign a value to a repeated...
Read more >repeated_field.h | Protocol Buffers - Google Developers
RepeatedField is used to represent repeated fields of a primitive type (in other ... Set(int index, const Element & value) ... Assign(Iter begin,...
Read more >Assignment with Repeated Indices - MathWorks Blogs
Repeated Indices with a Single Assignment. I initialize an output matrix to zeros and create two vectors, one with locations (indices) and ...
Read more >Class RepeatedField<T> (3.15.8) | .NET client library
Creates a deep clone of this repeated field. ... If the field type is a message type, each element is also cloned; otherwise,...
Read more >Repeated fields - Embedded Proto
To access the array and the elements in the repeated field various functions are generated in the message.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I took a look through the unit tests, and it seems that this exact situation is tested for (with the correct behavior expected). I think this is a somewhat recent addition by a third party contributor, thought. I will get the change packaged and out soon and see if that solves the problem.
Thanks @0x2b3bfa0 #178 does indeed appear to fix our issue.
@software-dov how soon do you think until 1.13.1 will get published to PyPi?