8000 bpo-42406: Fix whichmodule() with multiprocessing (GH-23403) · python/cpython@8668431 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8668431

Browse files
renatolfcgpshead
andauthored
bpo-42406: Fix whichmodule() with multiprocessing (GH-23403)
* bpo-42406: Fix whichmodule() with multiprocessing Signed-off-by: Renato L. de F. Cunha <renatoc@br.ibm.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
1 parent 86150d3 commit 8668431

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Lib/pickle.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ def whichmodule(obj, name):
340340
# Protect the iteration by using a list copy of sys.modules against dynamic
341341
# modules that trigger imports of other modules upon calls to getattr.
342342
for module_name, module in sys.modules.copy().items():
343-
if module_name == '__main__' or module is None:
343+
if (module_name == '__main__'
344+
or module_name == '__mp_main__' # bpo-42406
345+
or module is None):
344346
continue
345347
try:
346348
if _getattribute(module, name)[0] is obj:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
We fixed an issue in `pickle.whichmodule` in which importing
2+
`multiprocessing` could change the how pickle identifies which module an
3+
object belongs to, potentially breaking the unpickling of those objects.

0 commit comments

Comments
 (0)
0