protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Assigning to repeated field does not work

Open skrat opened this issue 1 year ago • 4 comments

What version of protobuf and what language are you using? Version: main/v4.25.2 Language: Python

What operating system (Linux, Windows, ...) and version?

Arch Linux

What runtime / compiler are you using (e.g., python version or gcc version)

Python 3.11.6

What did you do?

                    roof = [f for f in doc.faces if f.type == Face.Type.ROOF]
                    # doc.ClearField('faces')
                    # doc.faces.extend(roof)
                    doc.faces[:] = roof

What did you expect to see Success, no errors

What did you see instead?

  File "/home/skrat/Workspace/xxx/rwdom/backend/projects/management/commands/import.py", line 65, in handle
    doc.faces[:] = roof
    ~~~~~~~~~^^^
  File "/home/skrat/Workspace/xxx/rwdom/backend/.venv/lib/python3.11/site-packages/google/protobuf/internal/containers.py", line 348, in __setitem__
    raise TypeError(
TypeError: RepeatedCompositeFieldContainer object does not support item assignment

I know this is said in the lang. guide, but why tho? What's preventing you from making this work? Why can't we assign to repeated message fields?

skrat avatar Feb 01 '24 11:02 skrat

@anandolee Can you answer why assignment syntax doesn't work for repeated fields?

googleberg avatar Feb 17 '24 21:02 googleberg

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar May 18 '24 10:05 github-actions[bot]

I'll take a look at this myself, later.

skrat avatar May 20 '24 08:05 skrat

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Aug 18 '24 10:08 github-actions[bot]