dubiousjim added the comment:
In response to Issue #7105, self._pending_removals was added to
WeakValueDictionaries (and also WeakKeyDictionaries, but they're not relevant
to what I'm about to discuss). This was in changesets 58194 to tip and 58195 to
3.1, back in Jan 2010. In those changesets, the implementation of
WeakValueDictionary.setdefault acquired a check on self._pending_removals, but
only after the key lookup had failed. (See lines starting 5.127 in both those
changesets.)
In changeset 87778, in Dec 2013, this same patch was backported to 2.7.
More recently, in response to the issue discussed above (Issue #28427), similar
checks were added to WeakValueDictionary.get, but now BEFORE the key lookup.
This was in changesets 105851 to 3.5, 105852 to 3.6, 105853 to tip, and 105854
to 2.7, in Dec 2016. Notably, in the last changeset, the check on
self._pending_removals on WeakValueDictionary.setdefault is also moved to the
top of the function, before the key lookup is attempted. This parallels the
change being made to WeakValueDictionary.get.
However, that change to WeakValueDictionary.setdefault was only made to the 2.7
branch. If it's correct, then why wasn't the same also done for 3.5, 3.6, and
tip?
--
nosy: +dubiousjim
___
Python tracker
<http://bugs.python.org/issue28427>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com