From 25216baf3222e782fdeb5480b8692dc25dd7a97a Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 8 May 2010 19:52:21 +0000 Subject: Create __pycache__ dir when the pyc path is explicitly given Patch from Arfrever Frehtes Taifersar Arahesis. --- Lib/compileall.py | 6 ------ Lib/py_compile.py | 10 +++++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Lib/compileall.py b/Lib/compileall.py index ea2ee7f..49c3e6b 100644 --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -93,12 +93,6 @@ def compile_file(fullname, ddir=None, force=0, rx=None, quiet=False, cache_dir = os.path.dirname(cfile) 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) diff --git a/Lib/py_compile.py b/Lib/py_compile.py index 03f2c62..111893e 100644 --- a/Lib/py_compile.py +++ b/Lib/py_compile.py @@ -123,11 +123,11 @@ def compile(file, cfile=None, dfile=None, doraise=False): return if cfile is None: cfile = imp.cache_from_source(file) - try: - os.mkdir(os.path.dirname(cfile)) - except OSError as error: - if error.errno != errno.EEXIST: - raise + try: + os.makedirs(os.path.dirname(cfile)) + except OSError as error: + if error.errno != errno.EEXIST: + raise with open(cfile, 'wb') as fc: fc.write(b'\0\0\0\0') wr_long(fc, timestamp) -- cgit v0.12