[pypy-commit] pypy default: WeakValueDictionary has a bug that is rare on CPython but
arigo
noreply at buildbot.pypy.org
Sun Nov 10 10:07:06 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r67922:1f02ae2291ae
Date: 2013-11-10 09:54 +0100
http://bitbucket.org/pypy/pypy/changeset/1f02ae2291ae/
Log: WeakValueDictionary has a bug that is rare on CPython but more
common on PyPy. Fix it here and report it as
http://bugs.python.org/issue19542
diff --git a/lib-python/2.7/weakref.py b/lib-python/2.7/weakref.py
--- a/lib-python/2.7/weakref.py
+++ b/lib-python/2.7/weakref.py
@@ -160,22 +160,26 @@
try:
o = self.data.pop(key)()
except KeyError:
+ o = None
+ if o is None:
if args:
return args[0]
- raise
- if o is None:
raise KeyError, key
else:
return o
+ # The logic above was fixed in PyPy
def setdefault(self, key, default=None):
try:
- wr = self.data[key]
+ o = self.data[key]()
except KeyError:
+ o = None
+ if o is None:
self.data[key] = KeyedRef(default, self._remove, key)
return default
else:
- return wr()
+ return o
+ # The logic above was fixed in PyPy
def update(self, dict=None, **kwargs):
d = self.data
More information about the pypy-commit
mailing list