Commit 65959cab authored by Julien Muchembled's avatar Julien Muchembled Committed by Xavier Thompson

[fix] Fix redo_pyc for Python 3

parent 3dd224c2
...@@ -1621,20 +1621,31 @@ def redo_pyc(egg): ...@@ -1621,20 +1621,31 @@ def redo_pyc(egg):
chmod(dirpath) chmod(dirpath)
for filename in filenames: for filename in filenames:
filepath = os.path.join(dirpath, filename) filepath = os.path.join(dirpath, filename)
try:
chmod(filepath) chmod(filepath)
except OSError as e:
if e.errno != errno.ENOENT:
raise
continue
if not filename.endswith('.py'): if not filename.endswith('.py'):
continue 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 # If it wasn't compiled, it may not be compilable
continue continue
# OK, it looks like we should try to compile. # OK, it looks like we should try to compile.
# Remove old files. # Remove old files.
for suffix in 'co': for old in old:
if os.path.exists(filepath+suffix): os.remove(old)
os.remove(filepath+suffix)
# Compile under current optimization # Compile under current optimization
try: 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