STINNER Victor <[email protected]> added the comment:
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/mock.py b/Lib/unittest/mock.py
index c6067151de..1e3a8277ca 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1238,7 +1238,7 @@ def _dot_lookup(thing, comp, import_path):
try:
return getattr(thing, comp)
except AttributeError:
- __import__(import_path)
+ thing = __import__(import_path)
return getattr(thing, comp)
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45128>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com