Message9680
In Python 2.1.2, WeakValueDictionary.setdefault() is
broken:
Python 2.1.2 (#1, Jan 27 2002, 18:54:41)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)]
on linux2
Type "copyright", "credits" or "license" for more
information.
>>> import weakref
>>> d = weakref.WeakValueDictionary()
>>> class C: pass
...
>>> d.setdefault('yes', C())
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.1/weakref.py", line 91,
in setdefault
ref = ref(default, remove)
UnboundLocalError: local variable 'ref' referenced
before assignment
Attached is a simple patch, along with a test case.
This is a bug fix candidate for Python 2.1.3, should
there be one. It is not necessary for Python 2.2,
although you may want to port the test forward. |
|
Date |
User |
Action |
Args |
2007-08-23 13:59:47 | admin | link | issue529273 messages |
2007-08-23 13:59:47 | admin | create | |
|