Commit e3f11c25 authored by Julien Muchembled's avatar Julien Muchembled

Fix redo_pyc for Python 3

parent 16ed0283
......@@ -1692,20 +1692,31 @@ def redo_pyc(egg):
chmod(dirpath)
for filename in filenames:
filepath = os.path.join(dirpath, filename)
chmod(filepath)
try:
chmod(filepath)
except OSError as e:
if e.errno != errno.ENOENT:
raise
continue
if not filename.endswith('.py'):
continue
if not (os.path.exists(filepath+'c')
or os.path.exists(filepath+'o')):
old = []
pycache = os.path.join(dirpath, '__pycache__',
filename[:-3] + '.*.py')
for suffix in 'co':
if os.path.exists(filepath + suffix):
old.append(filepath + suffix)
old += glob.glob(pycache + suffix)
if not old:
# If it wasn't compiled, it may not be compilable
continue
# OK, it looks like we should try to compile.
# Remove old files.
for suffix in 'co':
if os.path.exists(filepath+suffix):
os.remove(filepath+suffix)
for old in old:
os.remove(old)
# Compile under current optimization
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment