protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Implement __iter__ in Python RepeatedScalarContainer

Open erik-hasse opened this issue 3 years ago • 3 comments

What language does this apply to? Python

Describe the problem you are trying to solve. The __iter__ attribute is commonly used to check whether an object is list-like, so neglecting to include it can cause issues, for example this bug in pandas: pandas-dev/pandas#42549. This results in weird behavior where list(obj) works fine even though hasattr(obj, '__iter__') is False.

Describe the solution you'd like The Python RepeatedScalarContainer should implement tp_iter in addition to tp_as_sequence.

Describe alternatives you've considered Manually convert to a list every time we use RepeatedScalarContainer (list(obj)).

erik-hasse avatar Jul 15 '21 15:07 erik-hasse

@zhangskz Are there any updates on this?

barshaul avatar Jan 16 '23 17:01 barshaul

Ping on this.

caneff avatar Nov 09 '23 17:11 caneff

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 Feb 20 '24 10:02 github-actions[bot]

This is still a problem, and internally at Google we still have to patch Pandas in order to make it work with proto repeated fields. Any updates as to fixing this?

caneff avatar Feb 21 '24 15:02 caneff

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 23 '24 10:05 github-actions[bot]

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 reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar Jun 07 '24 10:06 github-actions[bot]