Check if stdin has isatty attribute

When the stdin is closed, it has no isatty atrribute which leads to a KeyError.

Closes-Bug: #1980890
Change-Id: If9a3bf68b8dfd953b346697241166578d18bb563
This commit is contained in:
Benedikt Loeffler
2021-10-13 13:50:36 +02:00
committed by Cyril Roelandt
parent be8f394ab1
commit 8df9328a60
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -447,7 +447,7 @@ def get_data_file(args):
except OSError:
# (1) stdin is not valid (closed...)
return None
if not sys.stdin.isatty():
if hasattr(sys.stdin, 'isatty') and not sys.stdin.isatty():
# (2) image data is provided through standard input
image = sys.stdin
if hasattr(sys.stdin, 'buffer'):