Message87420
Running this code:
>>> import weakref
>>> class C: pass
...
>>> ws = weakref.WeakSet([C])
>>> if ws == 1:
... print(1)
...
gives me the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bob/python/svn/py3k/Lib/_weakrefset.py", line 121, in __eq__
return self.data == set(ref(item) for item in other)
TypeError: 'int' object is not iterable
Looking at _weakrefset.py line 121 gives
def __eq__(self, other):
return self.data == set(ref(item) for item in other)
which treats any 'other' object as a set like object. Therefore
comparing WeakSet to a non-set-like object always fails.
Do I understand it correctly and if so, is this the intended behavior? |
|
Date |
User |
Action |
Args |
2009-05-08 01:07:22 | schuppenies | set | recipients:
+ schuppenies |
2009-05-08 01:07:22 | schuppenies | set | messageid: <1241744842.61.0.823146195482.issue5964@psf.upfronthosting.co.za> |
2009-05-08 01:07:21 | schuppenies | link | issue5964 messages |
2009-05-08 01:07:20 | schuppenies | create | |
|