fix error message when file is not found
This commit is contained in:
parent
fbae8c1e53
commit
642f2b7328
1 changed files with 7 additions and 3 deletions
|
|
@ -77,11 +77,15 @@ class Pastoob(ReplApplication):
|
||||||
Submit a new paste.
|
Submit a new paste.
|
||||||
The filename can be '-' for reading standard input (pipe).
|
The filename can be '-' for reading standard input (pipe).
|
||||||
"""
|
"""
|
||||||
if filename is None or filename == '-':
|
if not filename or filename == '-':
|
||||||
contents = sys.stdin.read().decode(sys.stdin.encoding or locale.getpreferredencoding())
|
contents = sys.stdin.read().decode(sys.stdin.encoding or locale.getpreferredencoding())
|
||||||
else:
|
else:
|
||||||
with codecs.open(filename, encoding=locale.getpreferredencoding()) as fp:
|
try:
|
||||||
contents = fp.read()
|
with codecs.open(filename, encoding=locale.getpreferredencoding()) as fp:
|
||||||
|
contents = fp.read()
|
||||||
|
except IOError, e:
|
||||||
|
print >>sys.stderr, 'Unable to open file "%s": %s' % (filename, e.strerror)
|
||||||
|
return 1
|
||||||
|
|
||||||
# get and sort the backends able to satisfy our requirements
|
# get and sort the backends able to satisfy our requirements
|
||||||
params = self._get_params()
|
params = self._get_params()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue