New submission from Daniel Stutzbach <dan...@stutzbachenterprises.com>:
The documentation for weakref contains the following example: http://docs.python.org/3.1/library/weakref.html ---------------------------------------------- Several built-in types such as list and dict do not directly support weak references but can add support through subclassing: class Dict(dict): pass obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable ---------------------------------------------- While this works fine for list and dict, it does not work for tuple or int: >>> class Tuple(tuple): ... pass ... >>> obj = Tuple() >>> weakref.ref(obj) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: cannot create weak reference to 'Tuple' object I've tried it in Python 2.5, 2.6, and 3.1. ---------- components: Interpreter Core messages: 94260 nosy: stutzbach severity: normal status: open title: subclasses of (some) built-in types are not weakref-able type: behavior versions: Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7170> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com