Skip to content

[3.8] bpo-42406: Fix whichmodule() with multiprocessing (GH-23403) #23561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
We fixed an issue in `pickle.whichmodule` in which importing
`multiprocessing` could change the how pickle identifies which module an
object belongs to, potentially breaking the unpickling of those objects.