Improve error handling; don't die from unicode errors or syntax errors.

This commit is contained in:
Guido van Rossum 2007-07-15 13:01:48 +00:00
parent 8ac004e698
commit b7d3e65b3b
1 changed files with 9 additions and 3 deletions

View File

@ -67,11 +67,17 @@ def compile_dir(dir, maxlevels=10, ddir=None,
raise KeyboardInterrupt
except py_compile.PyCompileError as err:
if quiet:
print('Compiling', fullname, '...')
print('*** Error compiling', fullname, '...')
else:
print('*** ', end='')
print(err.msg)
success = 0
except IOError as e:
print("Sorry", e)
except (SyntaxError, UnicodeError, IOError) as e:
if quiet:
print('*** Error compiling', fullname, '...')
else:
print('*** ', end='')
print(e.__class__.__name__ + ':', e)
success = 0
else:
if ok == 0: