This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix in typo in WeakValueDictionary
Type: Stage:
Components: Extension Modules Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, nobody
Priority: normal Keywords: patch

Created on 2001-04-15 19:14 by anonymous, last changed 2022-04-10 16:03 by admin. This issue is now closed.

Messages (4)
msg36386 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-04-15 19:14
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
msg36387 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-04-18 04:35
Logged In: NO 

Ok, I submitted it the day before the 2.1 was released.

I has been fixed in the release. Nevermind.
msg36388 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-04-18 04:36
Logged In: NO 

Ok, I submitted it the day before the 2.1 was released.

I has been fixed in the release. Nevermind.
msg36389 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-05-09 19:48
Logged In: YES 
user_id=3066

This was fixed in Lib/weakref.py revision 1.8 (the version
included with Python 2.1).
History
Date User Action Args
2022-04-10 16:03:58adminsetgithub: 34343
2001-04-15 19:14:23anonymouscreate