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: weakref.WeakValueDictionary should override .has_key()
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: myers_carpenter, rhettinger
Priority: normal Keywords:

Created on 2004-08-19 16:39 by myers_carpenter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg22141 - (view) Author: Myers Carpenter (myers_carpenter) Date: 2004-08-19 16:39
.has_key() currently does not return the correct info
for a weakref.WeakValueDictionary.  When you call it
some times tells you that a key exists even tho the
value is no longer in RAM.
msg22142 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-08-19 21:49
Logged In: YES 
user_id=80475

I loaded a fix into Py2.4.  See Lib/weakref.py 1.25

What was there before should have worked fine but it is
possible that values were being deleted by GC or threads
after the internal has_key check and the return.  The patch
goes a step further and checks a lookedup object for a None
value.
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40789
2004-08-19 16:39:04myers_carpentercreate