From 67edc16652c9749b0b3a2d3218c91dc1558f260d Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Wed, 13 Mar 2002 05:47:26 +0000 Subject: [PATCH] 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. --- Lib/weakref.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 -- 2.47.3