summaryrefslogtreecommitdiff
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2014-12-01 17:10:10 -0500
committerBarry Warsaw <barry@python.org>2014-12-01 17:10:10 -0500
commit0f887a7f2778687a90353ee46a2569c5248068dc (patch)
treecf475c51b507cbd32a41cfe31e25039a1e8414d7 /Lib/importlib
parentcff8685224e9c1d0024aecfb87a2c120ca3a5542 (diff)
downloadcpython-0f887a7f2778687a90353ee46a2569c5248068dc.tar.gz
- Issue #22966: Fix __pycache__ pyc file name clobber when pyc_compile is
asked to compile a source file containing multiple dots in the source file name.
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index b8836c183d..5b91c05381 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -453,11 +453,11 @@ def cache_from_source(path, debug_override=None):
else:
suffixes = OPTIMIZED_BYTECODE_SUFFIXES
head, tail = _path_split(path)
- base_filename, sep, _ = tail.partition('.')
+ base, sep, rest = tail.rpartition('.')
tag = sys.implementation.cache_tag
if tag is None:
raise NotImplementedError('sys.implementation.cache_tag is None')
- filename = ''.join([base_filename, sep, tag, suffixes[0]])
+ filename = ''.join([(base if base else rest), sep, tag, suffixes[0]])
return _path_join(head, _PYCACHE, filename)