Bugs item #1170766, was opened at 2005-03-25 21:54 Message generated for change (Comment added) made by arigo You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1170766&group_id=5470
Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Alexander Kozlovsky (kozlovsky) Assigned to: Nobody/Anonymous (nobody) Summary: weakref.proxy incorrect behaviour Initial Comment: According documentation, proxy in most contexts must have the same behaviour as object itself. PROBLEM: bool(proxy_object) != bool(object_itself) EXAMPLE: >>> class X(list): pass # collection class ... >>> x = X() # empty collection >>> import weakref >>> proxy = weakref.proxy(x) >>> bool(x) False >>> bool(proxy) True PYTHON VERSION: 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] also tested on: 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] ---------------------------------------------------------------------- >Comment By: Armin Rigo (arigo) Date: 2005-03-26 14:50 Message: Logged In: YES user_id=4771 The bug is in weakrefobject:proxy_nonzero(), which calls the underlying object's nb_nonzero slot instead of going through the general PyObject_IsTrue() mecanism. Built-in types like list and dict don't have a nb_nonzero slot. As a related bug, (Callable)ProxyType should implement tp_richcompare in addition to tp_compare. In fact, we should review the code to check if ProxyType knows about the most recent type slots... ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1170766&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com