From: Fred Drake Date: Wed, 13 Mar 2002 05:47:26 +0000 (+0000) Subject: Fix SF bug #529273: WeakValueDictionary.setdefault() raised UnboundLocalError X-Git-Tag: v2.1.3~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67edc16652c9749b0b3a2d3218c91dc1558f260d;p=thirdparty%2FPython%2Fcpython.git Fix SF bug #529273: WeakValueDictionary.setdefault() raised UnboundLocalError since it used the name of a global function as the name of a local. The patch is almost identical to that submitted with the bug report. --- diff --git a/Lib/weakref.py b/Lib/weakref.py index b6b45282d065..7696c0fcb23e 100644 --- a/Lib/weakref.py +++ b/Lib/weakref.py @@ -84,15 +84,14 @@ class WeakValueDictionary(UserDict.UserDict): def setdefault(self, key, default): try: - ref = self.data[key] + wr = self.data[key] except KeyError: def remove(o, data=self.data, key=key): del data[key] - ref = ref(default, remove) - self.data[key] = ref + self.data[key] = ref(default, remove) return default else: - return ref() + return wr() def update(self, dict): d = self.data