mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Merge from 3.4 (for #21226).
This commit is contained in:
commit
b7f1be309e
5 changed files with 4331 additions and 4281 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue