Fix #29519: weakref spewing exceptions during interp finalization
authorŁukasz Langa <lukasz@langa.pl>
Fri, 10 Feb 2017 08:14:55 +0000 (00:14 -0800)
committerŁukasz Langa <lukasz@langa.pl>
Fri, 10 Feb 2017 08:14:55 +0000 (00:14 -0800)
Lib/weakref.py
Misc/NEWS

index aaebd0c464a179fec469d0aab40eff5143fd37ba..787e33a327c4f63e0ae874cfcbe6fdb8770d4271 100644 (file)
@@ -106,7 +106,7 @@ class WeakValueDictionary(collections.MutableMapping):
         self, *args = args
         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:
@@ -114,7 +114,7 @@ class WeakValueDictionary(collections.MutableMapping):
                 else:
                     # Atomic removal is necessary since this function
                     # can be called asynchronously by the GC
-                    _remove_dead_weakref(d, wr.key)
+                    _atomic_removal(d, wr.key)
         self._remove = remove
         # A list of keys to be removed
         self._pending_removals = []
index fa0e740836984f962fafad036efcc759662d3468..e1b32add0ef3ca829253b38d0db2ab07a4145ab0 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -23,6 +23,9 @@ Extension Modules
 Library
 -------
 
+- Issue #29519: Fix weakref spewing exceptions during interpreter shutdown
+  when used with a rare combination of multiprocessing and custom codecs.
+
 - Issue #29416: Prevent infinite loop in pathlib.Path.mkdir
 
 - Issue #29444: Fixed out-of-bounds buffer access in the group() method of