Author arigo
Recipients arigo
Date 2013-11-10.08:51:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1384073464.47.0.0676946313386.issue19542@psf.upfronthosting.co.za>
In-reply-to
Content
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 "self.data" 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.
History
Date User Action Args
2013-11-10 08:51:04arigosetrecipients: + arigo
2013-11-10 08:51:04arigosetmessageid: <1384073464.47.0.0676946313386.issue19542@psf.upfronthosting.co.za>
2013-11-10 08:51:04arigolinkissue19542 messages
2013-11-10 08:51:03arigocreate