summaryrefslogtreecommitdiff
path: root/Lib/weakref.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-09-09 16:55:58 +0200
committerGitHub <noreply@github.com>2019-09-09 16:55:58 +0200
commita2af05a0d3f0da06b8d432f52efa3ecf29038532 (patch)
tree3cdd6eee59dc6568efd7abe1b15fe1a863d86329 /Lib/weakref.py
parentb3b48c81f09d1472010937f1331c5a208a2a2d48 (diff)
downloadcpython-git-a2af05a0d3f0da06b8d432f52efa3ecf29038532.tar.gz
bpo-38006: Avoid closure in weakref.WeakValueDictionary (GH-15641)
weakref.WeakValueDictionary defines a local remove() function used as callback for weak references. This function was created with a closure. Modify the implementation to avoid the closure.
Diffstat (limited to 'Lib/weakref.py')
-rw-r--r--Lib/weakref.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/weakref.py b/Lib/weakref.py
index 560deee96c..d17b3ed38e 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -108,12 +108,12 @@ class WeakValueDictionary(_collections_abc.MutableMapping):
else:
# Atomic removal is necessary since this function
# can be called asynchronously by the GC
- _atomic_removal(d, wr.key)
+ _atomic_removal(self.data, wr.key)
self._remove = remove
# A list of keys to be removed
self._pending_removals = []
self._iterating = set()
- self.data = d = {}
+ self.data = {}
self.update(other, **kw)
def _commit_removals(self):