New submission from Antoine Pitrou: Dead weakrefs to a given object happen to be equal if they don't have a callback, but unequal if they do. However, they are always equal when alive:
>>> class O: pass ... >>> o = O() >>> def cb(_): pass ... >>> q = weakref.ref(o) >>> r = weakref.ref(o) >>> s = weakref.ref(o, cb) >>> t = weakref.ref(o, cb) >>> q == r True >>> s == t True >>> del o >>> q() is None True >>> q == r True >>> s == t False This may be related to the following optimization (?): >>> q is r True >>> s is t False ---------- components: Library (Lib) messages: 175378 nosy: fdrake, pitrou, tim_one priority: normal severity: normal status: open title: Inconsistent dead weakref equality type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16453> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com