mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Check that the file exists instead of raising an ugly Python exception.
This commit is contained in:
parent
e3632d8a64
commit
b8a27bbcd2
1 changed files with 7 additions and 1 deletions
6
main.py
6
main.py
|
@ -477,7 +477,13 @@ def main(argv):
|
||||||
if fname == '-':
|
if fname == '-':
|
||||||
script = sys.stdin.read()
|
script = sys.stdin.read()
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
f = open(fname, 'r')
|
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:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue