From 6ecb0a19cfd573253991b157e95a005093316a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 25 Mar 2020 22:30:24 +0100 Subject: [PATCH] handle sys.stdin being None when using '-' as input file (#653) --- gallery_dl/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index 04aff5117d..e71a5b084f 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -205,11 +205,13 @@ def main(): if args.inputfile: try: if args.inputfile == "-": - file = sys.stdin + if sys.stdin: + urls += parse_inputfile(sys.stdin, log) + else: + log.warning("input file: stdin is not readable") else: - file = open(args.inputfile, encoding="utf-8") - urls += parse_inputfile(file, log) - file.close() + with open(args.inputfile, encoding="utf-8") as file: + urls += parse_inputfile(file, log) except OSError as exc: log.warning("input file: %s", exc)