From 3eb80957743900a7a2d3dab65c95175987b19c2b Mon Sep 17 00:00:00 2001 From: faucct Date: Tue, 21 Sep 2021 14:16:27 +0300 Subject: [PATCH] [3.7] bpo-42406: Fix whichmodule() with multiprocessing (pythonGH-23403) --- Lib/pickle.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/pickle.py b/Lib/pickle.py index bfa3c0361b73c6..d7192fea8e396d 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -307,7 +307,9 @@ def whichmodule(obj, name): # Protect the iteration by using a list copy of sys.modules against dynamic # modules that trigger imports of other modules upon calls to getattr. for module_name, module in list(sys.modules.items()): - if module_name == '__main__' or module is None: + if (module_name == '__main__' + or module_name == '__mp_main__' # bpo-42406 + or module is None): continue try: if _getattribute(module, name)[0] is obj: