summaryrefslogtreecommitdiffstats
path: root/Lib/imp.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2015-09-05 11:05:05 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2015-09-05 11:05:05 (GMT)
commit9d3c61c86a20678d604c96a68bbf4a966877f0b9 (patch)
tree77e38b72e9258da435606d28543cc0362787eeff /Lib/imp.py
parent1b6691053701e92490c6b68171d6d6a645f8e708 (diff)
downloadcpython-9d3c61c86a20678d604c96a68bbf4a966877f0b9.zip
cpython-9d3c61c86a20678d604c96a68bbf4a966877f0b9.tar.gz
cpython-9d3c61c86a20678d604c96a68bbf4a966877f0b9.tar.bz2
Close #24748: Restore imp.load_dynamic compatibility
To resolve a compatibility problem found with py2exe and pywin32, imp.load_dynamic() once again ignores previously loaded modules to support Python modules replacing themselves with extension modules. Patch by Petr Viktorin.
Diffstat (limited to 'Lib/imp.py')
-rw-r--r--Lib/imp.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/imp.py b/Lib/imp.py
index 2cd6440..f6fff44 100644
--- a/Lib/imp.py
+++ b/Lib/imp.py
@@ -334,6 +334,12 @@ if create_dynamic:
"""
import importlib.machinery
loader = importlib.machinery.ExtensionFileLoader(name, path)
- return loader.load_module()
+
+ # Issue #24748: Skip the sys.modules check in _load_module_shim;
+ # always load new extension
+ spec = importlib.machinery.ModuleSpec(
+ name=name, loader=loader, origin=path)
+ return _load(spec)
+
else:
load_dynamic = None