From 140b64d5cb269dedd08984ef950e5d5e6ecfb215 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sat, 13 Nov 2021 21:03:34 +0300 Subject: [PATCH] Better fix for #307 is to return text stream from Popen `universal_newlines` make this in compatible way with older Python. --- lib/fetch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/fetch.py b/lib/fetch.py index bd5b63b..7b1bc62 100644 --- a/lib/fetch.py +++ b/lib/fetch.py @@ -57,13 +57,15 @@ def fetch_all(skip_existing=True): sys.stdout.write("Fetching %s..." % (adptr)) sys.stdout.flush() try: - process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + process = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + universal_newlines=True) except OSError: print("\nERROR: %s" % cmd) raise output = process.communicate()[0] if process.returncode != 0: - sys.stdout.write("\nERROR:\n---\n" + str(output)) + sys.stdout.write("\nERROR:\n---\n" + output) fatal("---\nCould not fetch %s" % adptr) else: print("Done")