]> granicus.if.org Git - python/commitdiff
Create __pycache__ dir when the pyc path is explicitly given
authorBenjamin Peterson <benjamin@python.org>
Sat, 8 May 2010 19:52:21 +0000 (19:52 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 8 May 2010 19:52:21 +0000 (19:52 +0000)
Patch from Arfrever Frehtes Taifersar Arahesis.

Lib/compileall.py
Lib/py_compile.py

index ea2ee7fbb6c48e6e3d657ab255d31be28609d55b..49c3e6b920468ce67463e9378efe498a55bc331e 100644 (file)
@@ -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)
index 03f2c6279d1aa5ea8ac45c5b63f0bb3842af681c..111893efc53b944884b551e47cf7f987220be7b4 100644 (file)
@@ -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)