]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-120170: Exclude __mp_main__ in C version of whichmodule() (#120171)
authorDaniel Li <daniel.li@deshaw.com>
Fri, 23 May 2025 18:45:45 +0000 (14:45 -0400)
committerGitHub <noreply@github.com>
Fri, 23 May 2025 18:45:45 +0000 (21:45 +0300)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Misc/NEWS.d/next/Library/2024-06-06-17-49-07.gh-issue-120170.DUxhmT.rst [new file with mode: 0644]
Modules/_pickle.c

diff --git a/Misc/NEWS.d/next/Library/2024-06-06-17-49-07.gh-issue-120170.DUxhmT.rst b/Misc/NEWS.d/next/Library/2024-06-06-17-49-07.gh-issue-120170.DUxhmT.rst
new file mode 100644 (file)
index 0000000..ce7d874
--- /dev/null
@@ -0,0 +1,3 @@
+Fix an issue in the :mod:`!_pickle` extension module in which importing
+:mod:`multiprocessing` could change how pickle identifies which module an
+object belongs to, potentially breaking the unpickling of those objects.
index d260f1a68f8c7041823a7bd518095fe815b9974b..29ef0cb0c2e0882f3ef2185b1950c1a367f2cd3d 100644 (file)
@@ -1879,6 +1879,10 @@ _checkmodule(PyObject *module_name, PyObject *module,
             _PyUnicode_EqualToASCIIString(module_name, "__main__")) {
         return -1;
     }
+    if (PyUnicode_Check(module_name) &&
+            _PyUnicode_EqualToASCIIString(module_name, "__mp_main__")) {
+        return -1;
+    }
 
     PyObject *candidate = getattribute(module, dotted_path, 0);
     if (candidate == NULL) {