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: