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: WeakValueDictionary.__init__ is backwards
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, georg.brandl, mcfletch, ppergame, rhettinger
Priority: normal Keywords:

Created on 2005-05-06 01:59 by ppergame, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg25240 - (view) Author: Pavel Pergamenshchik (ppergame) Date: 2005-05-06 01:59
>>> from weakref import WeakValueDictionary as wvd
>>> class A:
...     pass
... 
>>> wvd({1:A()})
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/weakref.py", line 46, in
__init__
    UserDict.UserDict.__init__(self, *args, **kw)
  File "/usr/lib/python2.4/UserDict.py", line 7, in
__init__
    self.update(dict)
  File "/usr/lib/python2.4/weakref.py", line 161, in update
    d[key] = KeyedRef(o, self._remove, key)
AttributeError: WeakValueDictionary instance has no
attribute '_remove'


WeakValueDictionary.__init__ calls UserDict.__init__
first and sets self._remove second. It should do it the
other way around. This is a regression from 2.3.
msg25241 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-05-10 03:36
Logged In: YES 
user_id=80475

Fred, I believe this was your change (1.23).
The OP's request apprears correct to me.
msg25242 - (view) Author: Mike C. Fletcher (mcfletch) Date: 2005-05-11 19:23
Logged In: YES 
user_id=34901

I would agree that the order is definitely broken.
msg25243 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-06-04 07:19
Logged In: YES 
user_id=1188172

Okay to checkin?
msg25244 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-06-04 09:21
Logged In: YES 
user_id=1188172

Thanks for the report. Committed as Lib/weakref.py r1.27
r1.26.2.1.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 41952
2005-05-06 01:59:22ppergamecreate