From de6c8305ff1ac35ac6410a0df35febd5faf491e6 Mon Sep 17 00:00:00 2001 From: earonesty Date: Tue, 25 Jan 2022 11:40:23 -0500 Subject: [PATCH] fix stdin read should be bytes, not textmode --- patch.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/patch.py b/patch.py index 4775d70..160344d 100755 --- a/patch.py +++ b/patch.py @@ -44,6 +44,11 @@ else: compat_next = lambda gen: gen.__next__() +if PY3K: + compat_stdin = sys.stdin.buffer +else: + compat_stdin = sys.stdin + def tostr(b): """ Python 3 bytes encoder. Used to print filename in diffstat output. Assumes that filenames are in utf-8. @@ -1163,7 +1168,7 @@ def main(): setdebug() # this sets global debugmode variable if readstdin: - patch = PatchSet(sys.stdin) + patch = PatchSet(compat_stdin) else: patchfile = args[0] urltest = patchfile.split(':')[0]