- 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.
This commit is contained in:
Barry Warsaw 2014-12-01 17:52:43 -05:00
commit d32d4ae4ca
4 changed files with 3528 additions and 3506 deletions

View file

@ -454,11 +454,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)