summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-04-21 22:52:52 (GMT)
committerBrett Cannon <brett@python.org>2012-04-21 22:52:52 (GMT)
commita64faf0771bceee789dd345202919147f595bfd3 (patch)
tree2a53ef6ed0455c8979351ee8e5fff6ce7d6331b9 /Lib/importlib
parentea59dbff16e305aa07ef5896cc59fb36dc5edac3 (diff)
downloadcpython-a64faf0771bceee789dd345202919147f595bfd3.zip
cpython-a64faf0771bceee789dd345202919147f595bfd3.tar.gz
cpython-a64faf0771bceee789dd345202919147f595bfd3.tar.bz2
Issue #13959: Re-implement imp.source_from_cache() in Lib/imp.py.
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 44bac39..ea98a68 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -180,6 +180,8 @@ def _new_module(name):
PYCACHE = '__pycache__'
+SOURCE_SUFFIXES = ['.py'] # _setup() adds .pyw as needed.
+
DEBUG_BYTECODE_SUFFIX = '.pyc'
OPT_BYTECODE_SUFFIX = '.pyo'
BYTECODE_SUFFIX = DEBUG_BYTECODE_SUFFIX if __debug__ else OPT_BYTECODE_SUFFIX
@@ -199,7 +201,7 @@ def _cache_from_source(path, debug_override=None):
suffix = DEBUG_BYTECODE_SUFFIX if debug else OPT_BYTECODE_SUFFIX
head, tail = _path_split(path)
base_filename, sep, _ = tail.partition('.')
- filename = '{}{}{}{}'.format(base_filename, sep, _imp.get_tag(), suffix)
+ filename = ''.join([base_filename, sep, _imp.get_tag(), suffix])
return _path_join(head, PYCACHE, filename)
@@ -1195,6 +1197,8 @@ def _setup(sys_module, _imp_module):
# Constants
setattr(self_module, '_relax_case', _make_relax_case())
setattr(self_module, '_MAGIC_NUMBER', _imp_module.get_magic())
+ if builtin_os == 'nt':
+ SOURCE_SUFFIXES.append('.pyw')
def _install(sys_module, _imp_module):