[Patches] [ python-Patches-416298 ] Fix in typo in WeakValueDictionary
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 17 Apr 2001 21:36:15 -0700
Patches item #416298, was updated on 2001-04-15 12:14
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=416298&group_id=5470
Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Fix in typo in WeakValueDictionary
Initial Comment:
There is a small error in weakref.WeakValueDictionary.
This error was found in 2.1c1, a quick look in the
april 15th build revealed it was not fixed.
Demonstration:
>>> class Spam:
... pass
...
>>> dict = {'a':Spam()}
>>> weakref.WeakValueDictionary(dict)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"/usr/local/python-2.1c1/lib/python2.1/UserDict.py",
line 6, in __init__
if dict is not None: self.update(dict)
File
"/usr/local/python-2.1c1/lib/python2.1/weakref.py",
line 103, in update
L.append(key, ref(o, remove))
Examination of the script reveals that the fix is obvious:
def update(self, dict):
d = self.data
L = []
for key, o in dict.items():
def remove(o, data=d, key=key):
del data[key]
# L.append(key, ref(o, remove))
# ^^^ erroneous ^^^^
L.append((key, ref(o, remove)))
# ^^^ right ^^^
for key, r in L:
d[key] = r
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2001-04-17 21:36
Message:
Logged In: NO
Ok, I submitted it the day before the 2.1 was released.
I has been fixed in the release. Nevermind.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2001-04-17 21:35
Message:
Logged In: NO
Ok, I submitted it the day before the 2.1 was released.
I has been fixed in the release. Nevermind.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=416298&group_id=5470