Check that the file exists instead of raising an ugly Python exception.

This commit is contained in:
Sei Lisa 2016-12-26 03:00:22 +01:00
parent e3632d8a64
commit b8a27bbcd2

View file

@ -477,7 +477,13 @@ def main(argv):
if fname == '-':
script = sys.stdin.read()
else:
f = open(fname, 'r')
try:
f = open(fname, 'r')
except IOError as e:
if e.errno == 2:
sys.stderr.write('Error: File not found: %s\n' % fname)
return 2
raise
try:
script = f.read()
finally: