summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2014-05-13 00:25:00 (GMT)
committerEric Snow <ericsnowcurrently@gmail.com>2014-05-13 00:25:00 (GMT)
commitb7f1be309eb7d2deceb8b6c3f3a4de1e4dcbbe11 (patch)
tree657316c7a5016968c0e031e057250a5670db388e /Lib/importlib
parent38d3d22b29abed5a92166b86dddbbc575cf4ae02 (diff)
parent08197a4616f6294e21672fd8ebb5da7ce956c8e5 (diff)
downloadcpython-b7f1be309eb7d2deceb8b6c3f3a4de1e4dcbbe11.zip
cpython-b7f1be309eb7d2deceb8b6c3f3a4de1e4dcbbe11.tar.gz
cpython-b7f1be309eb7d2deceb8b6c3f3a4de1e4dcbbe11.tar.bz2
Merge from 3.4 (for #21226).
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 6b8c9ea..705c393 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1221,6 +1221,29 @@ class _SpecMethods:
return self._load_unlocked()
+def _fix_up_module(ns, name, pathname, cpathname=None):
+ # This function is used by PyImport_ExecCodeModuleObject().
+ loader = ns.get('__loader__')
+ spec = ns.get('__spec__')
+ if not loader:
+ if spec:
+ loader = spec.loader
+ elif pathname == cpathname:
+ loader = SourcelessFileLoader(name, pathname)
+ else:
+ loader = SourceFileLoader(name, pathname)
+ if not spec:
+ spec = spec_from_file_location(name, pathname, loader=loader)
+ try:
+ ns['__spec__'] = spec
+ ns['__loader__'] = loader
+ ns['__file__'] = pathname
+ ns['__cached__'] = cpathname
+ except Exception:
+ # Not important enough to report.
+ pass
+
+
# Loaders #####################################################################
class BuiltinImporter: