Commits

Anonymous committed 09a2d9e

err-reporting in input opening

Comments (0)

Files changed (1)

     return iter(unicode_file(input, *args, **kwargs))
 
 def open_input(options, **kwargs):
-    input = sys.stdin if options.input == "-" else open(options.input, 'rb')
+    input = sys.stdin
+    if options.input != "-":
+        try:
+            input = open(options.input, 'rb')
+        except Exception:
+            die("%r cannot be opened" % options.input)
     encoding = kwargs.get('encoding', getattr(options, 'encoding', None))
     if encoding is not None:
         input = unicode_file(input, encoding=encoding, **kwargs)