Index: Lib/compileall.py =================================================================== --- Lib/compileall.py (revision 81004) +++ Lib/compileall.py (working copy) @@ -93,12 +93,6 @@ 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: Lib/py_compile.py =================================================================== --- Lib/py_compile.py (revision 81004) +++ Lib/py_compile.py (working copy) @@ -123,11 +123,11 @@ 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)