[Python-checkins] bpo-29519: weakref spewing exceptions during interp finalization (#2958)

Łukasz Langa webhook-mailer at python.org
Mon Jul 31 13:52:49 EDT 2017


https://github.com/python/cpython/commit/3e37f4a11547a226c3c2f8bd612510465db397b9
commit: 3e37f4a11547a226c3c2f8bd612510465db397b9
branch: 2.7
author: INADA Naoki <methane at users.noreply.github.com>
committer: Łukasz Langa <lukasz at langa.pl>
date: 2017-07-31T10:52:46-07:00
summary:

bpo-29519: weakref spewing exceptions during interp finalization (#2958)

(cherry pick from 9cd7e17640a49635d1c1f8c2989578a8fc2c1de6)

files:
A Misc/NEWS.d/next/Library/2017-07-31-19-32-57.bpo-29519._j1awg.rst
M Lib/weakref.py

diff --git a/Lib/weakref.py b/Lib/weakref.py
index c66943f02e2..3e1fb815806 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -53,7 +53,7 @@ def __init__(*args, **kw):
         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 @@ def remove(wr, selfref=ref(self)):
                 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
index 00000000000..9b2e39d3318
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2017-07-31-19-32-57.bpo-29519._j1awg.rst
@@ -0,0 +1,2 @@
+Fix weakref spewing exceptions during interpreter shutdown when used with a
+rare combination of multiprocessing and custom codecs.



More information about the Python-checkins mailing list