Message401333
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) |
|
Date |
User |
Action |
Args |
2021-09-07 19:25:37 | vstinner | set | recipients:
+ vstinner, pablogsal, sobolevn |
2021-09-07 19:25:37 | vstinner | set | messageid: <1631042737.52.0.646534325927.issue45128@roundup.psfhosted.org> |
2021-09-07 19:25:37 | vstinner | link | issue45128 messages |
2021-09-07 19:25:37 | vstinner | create | |
|