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

fix: Revert algorithm for RepeatedComposite insertion. #101

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion proto/marshal/collections/repeated.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,10 @@ def __setitem__(self, key, value):
def insert(self, index: int, value):
"""Insert ``value`` in the sequence before ``index``."""
pb_value = self._marshal.to_proto(self._pb_type, value, strict=True)
self.pb.insert(index, pb_value)

# Protocol buffers does not define a useful insert, so we have
# to pop everything after this point off the list and reload it.
after = [pb_value]
while self.pb[index:]:
after.append(self.pb.pop(index))
self.pb.extend(after)