This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author schuppenies
Recipients schuppenies
Date 2009-05-08.01:07:20
SpamBayes Score 1.6695524e-09
Marked as misclassified No
Message-id <1241744842.61.0.823146195482.issue5964@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2009-05-08 01:07:22schuppeniessetrecipients: + schuppenies
2009-05-08 01:07:22schuppeniessetmessageid: <1241744842.61.0.823146195482.issue5964@psf.upfronthosting.co.za>
2009-05-08 01:07:21schuppenieslinkissue5964 messages
2009-05-08 01:07:20schuppeniescreate