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

TypeError: 'NoneType' object is not iterable when testing equality of repeated composite or scalar #476

Closed
parthea opened this issue Jul 13, 2024 · 0 comments · Fixed by #477
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@parthea
Copy link
Contributor

parthea commented Jul 13, 2024

Steps to reproduce

Repeated Composite

>>> import proto
>>> class Foo(proto.Message):
...     bar = proto.Field(proto.INT32, number=1)
... 
>>> class Baz(proto.Message):
...     foos = proto.RepeatedField(proto.MESSAGE, message=Foo, number=1)
... 
>>> baz = Baz(foos=[Foo(bar=42)])
>>> assert baz.foos != None

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/google/home/partheniou/git/proto-plus-python/proto/marshal/collections/repeated.py", line 63, in __ne__
    return not self == other
  File "/usr/local/google/home/partheniou/git/proto-plus-python/proto/marshal/collections/repeated.py", line 121, in __eq__
    if super().__eq__(other):
  File "/usr/local/google/home/partheniou/git/proto-plus-python/proto/marshal/collections/repeated.py", line 52, in __eq__
    return tuple(self.pb) == tuple(other)
TypeError: 'NoneType' object is not iterable

Repeated Scalar

>>> import proto
>>> class Foo(proto.Message):
...     bar = proto.RepeatedField(proto.INT32, number=1)
... 
>>> foo = Foo(bar=[1, 1, 2, 3, 5, 8, 13])
>>> assert foo.bar != None

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/google/home/partheniou/git/proto-plus-python/proto/marshal/collections/repeated.py", line 63, in __ne__
    return not self == other
  File "/usr/local/google/home/partheniou/git/proto-plus-python/proto/marshal/collections/repeated.py", line 52, in __eq__
    return tuple(self.pb) == tuple(other)
TypeError: 'NoneType' object is not iterable
@parthea parthea added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant