mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Bug 8563 - compileall.compile_file() creates empty __pycache__ directories in
data directories where there is no source. Fix by: Arfrever Frehtes Taifersar Arahesis (Arfrever) Test by: Barry
This commit is contained in:
parent
d5334e1fa3
commit
c8a99de751
2 changed files with 19 additions and 5 deletions
|
|
@ -91,13 +91,14 @@ def compile_file(fullname, ddir=None, force=0, rx=None, quiet=False,
|
|||
else:
|
||||
cfile = imp.cache_from_source(fullname)
|
||||
cache_dir = os.path.dirname(cfile)
|
||||
try:
|
||||
os.mkdir(cache_dir)
|
||||
except OSError as error:
|
||||
if error.errno != errno.EEXIST:
|
||||
raise
|
||||
head, tail = name[:-3], name[-3:]
|
||||
if tail == '.py':
|
||||
if not legacy:
|
||||
try:
|
||||
os.mkdir(cache_dir)
|
||||
except OSError as error:
|
||||
if error.errno != errno.EEXIST:
|
||||
raise
|
||||
if not force:
|
||||
try:
|
||||
mtime = int(os.stat(fullname).st_mtime)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue