Author vstinner
Recipients pablogsal, sobolevn, vstinner
Date 2021-09-07.19:25:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I'm not sure if unittest.mock code to import the module is reliable: see bpo-39551. It imports "multiprocessing", use getattr() to get multiprocessing.shared_memory. If getattr() fails with AttributeError, it tries to import "mulitprocessing.shared_memory", and then tries again the same getattr() on the previously imported "multiprocessing" module.

I'm curious if this change works around the issue:

diff --git a/Lib/unittest/ b/Lib/unittest/
index c6067151de..1e3a8277ca 100644
--- a/Lib/unittest/
+++ b/Lib/unittest/
@@ -1238,7 +1238,7 @@ def _dot_lookup(thing, comp, import_path):
         return getattr(thing, comp)
     except AttributeError:
-        __import__(import_path)
+        thing = __import__(import_path)
         return getattr(thing, comp)
Date User Action Args
2021-09-07 19:25:37vstinnersetrecipients: + vstinner, pablogsal, sobolevn
2021-09-07 19:25:37vstinnersetmessageid: <>
2021-09-07 19:25:37vstinnerlinkissue45128 messages
2021-09-07 19:25:37vstinnercreate