Check that the file exists instead of raising an ugly Python exception.
This commit is contained in:
8
main.py
8
main.py
@@ -477,7 +477,13 @@ def main(argv):
|
|||||||
if fname == '-':
|
if fname == '-':
|
||||||
script = sys.stdin.read()
|
script = sys.stdin.read()
|
||||||
else:
|
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:
|
try:
|
||||||
script = f.read()
|
script = f.read()
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in New Issue
Block a user