From 86684319d3dad8e1a7b0559727a48e0bc50afb01 Mon Sep 17 00:00:00 2001 From: Renato Cunha Date: Sun, 29 Nov 2020 15:23:15 -0300 Subject: bpo-42406: Fix whichmodule() with multiprocessing (GH-23403) * bpo-42406: Fix whichmodule() with multiprocessing Signed-off-by: Renato L. de F. Cunha Co-authored-by: Gregory P. Smith --- Lib/pickle.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Lib/pickle.py') diff --git a/Lib/pickle.py b/Lib/pickle.py index cbac5f168b..e63a8b6e4d 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -340,7 +340,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 sys.modules.copy().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: -- cgit v1.2.1