]> granicus.if.org Git - python/commitdiff
bpo-29519: weakref spewing exceptions during interp finalization (#2958)
authorINADA Naoki <methane@users.noreply.github.com>
Mon, 31 Jul 2017 17:52:46 +0000 (02:52 +0900)
committerŁukasz Langa <lukasz@langa.pl>
Mon, 31 Jul 2017 17:52:46 +0000 (10:52 -0700)
(cherry pick from 9cd7e17640a49635d1c1f8c2989578a8fc2c1de6)

Lib/weakref.py
Misc/NEWS.d/next/Library/2017-07-31-19-32-57.bpo-29519._j1awg.rst [new file with mode: 0644]

index c66943f02e24a7807be3e960461ba128beefdc3f..3e1fb81580692424a1d94e29852daba07ce132ff 100644 (file)
@@ -53,7 +53,7 @@ class WeakValueDictionary(UserDict.UserDict):
         args = args[1:]
         if len(args) > 1:
             raise TypeError('expected at most 1 arguments, got %d' % len(args))
-        def remove(wr, selfref=ref(self)):
+        def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
             self = selfref()
             if self is not None:
                 if self._iterating:
@@ -61,7 +61,7 @@ class WeakValueDictionary(UserDict.UserDict):
                 else:
                     # Atomic removal is necessary since this function
                     # can be called asynchronously by the GC
-                    _remove_dead_weakref(self.data, wr.key)
+                    _atomic_removal(self.data, wr.key)
         self._remove = remove
         # A list of keys to be removed
         self._pending_removals = []
diff --git a/Misc/NEWS.d/next/Library/2017-07-31-19-32-57.bpo-29519._j1awg.rst b/Misc/NEWS.d/next/Library/2017-07-31-19-32-57.bpo-29519._j1awg.rst
new file mode 100644 (file)
index 0000000..9b2e39d
--- /dev/null
@@ -0,0 +1,2 @@
+Fix weakref spewing exceptions during interpreter shutdown when used with a
+rare combination of multiprocessing and custom codecs.