summaryrefslogtreecommitdiffstats
path: root/Lib/compileall.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2010-04-29 18:43:10 (GMT)
committerBarry Warsaw <barry@python.org>2010-04-29 18:43:10 (GMT)
commitc8a99de7513abe90716750090658e7e910664822 (patch)
treec44c51f45370b224f570a8c856cfd9b4fa2b784b /Lib/compileall.py
parentd5334e1fa3fbc17c01f580a6efc2817720c63476 (diff)
downloadcpython-c8a99de7513abe90716750090658e7e910664822.zip
cpython-c8a99de7513abe90716750090658e7e910664822.tar.gz
cpython-c8a99de7513abe90716750090658e7e910664822.tar.bz2
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
Diffstat (limited to 'Lib/compileall.py')
-rw-r--r--Lib/compileall.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/compileall.py b/Lib/compileall.py
index be9e2ad..ea2ee7f 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -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)