Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment of item at index in repeated field #188

Closed
BenRKarl opened this issue Feb 18, 2021 · 6 comments
Closed

Assignment of item at index in repeated field #188

BenRKarl opened this issue Feb 18, 2021 · 6 comments
Labels
triage me I really want to be triaged.

Comments

@BenRKarl
Copy link

With 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]
@software-dov
Copy link
Contributor

To clarify, this bug seems to indicate that element assignment in a repeated field is incorrectly being interpreted as insertion.

@BenRKarl
Copy link
Author

Yes exactly.

@software-dov
Copy link
Contributor

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.

@BenRKarl
Copy link
Author

Interesting - can you point me to where the unit tests are? Maybe we have a corner case that we can add a test for.

@0x2b3bfa0
Copy link
Contributor

0x2b3bfa0 commented Feb 19, 2021

Possible duplicate of #177, allegedly fixed through #178. @BenRKarl, please check the latter for more information about the location of the affected unit tests.

Salutations from the third party contributor. 😉

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Feb 19, 2021
@BenRKarl
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

4 participants