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.

Author arigo
Recipients arigo
Date 2013-11-10.08:51:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
WeakValueDictionary.setdefault() contains a bug that shows up in multithreaded situations using reference cycles.  Attached a test case: it is possible for 'setdefault(key, default)' to return None, although None is never put as a value in the dictionary.  (Actually, being a WeakValueDictionary, None is not allowed as a value.)

The reason is that the code in setdefault() ends in "return wr()", but the weakref "wr" might have gone invalid between the time it was fetched from "" and the "wr()" itself, thus returning None.

A similar problem occurs in pop(), leading it to possibly raise KeyError even if it is called with a default argument.
Date User Action Args
2013-11-10 08:51:04arigosetrecipients: + arigo
2013-11-10 08:51:04arigosetmessageid: <>
2013-11-10 08:51:04arigolinkissue19542 messages
2013-11-10 08:51:03arigocreate