From 6e566ade3b0907121b71d4c2c56b7e0d3169bf06 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 10 2019 11:26:57 +0000 Subject: Decode the output from the shell commands if they are not already unicode We're relying on six.binary_type to distinguish between str in py2 and bytes in py3, both of which needed to be converted to unicode. Fixes https://pagure.io/pagure/issue/4188 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index fd6846b..db0a10a 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -1215,16 +1215,16 @@ def read_output(cmd, abspath, input=None, keepends=False, error=False, **kw): ) retcode = procs.wait() (out, err) = procs.communicate(input) - if not isinstance(out, str): + if isinstance(out, six.binary_type): out = out.decode("utf-8") - if not isinstance(err, str): + if isinstance(err, six.binary_type): err = err.decode("utf-8") if retcode: print("ERROR: %s =-- %s" % (cmd, retcode)) print(out) print(err) if not keepends: - out = out.rstrip("\n\r") + out = out.rstrip(u"\n\r") if error: return (out, err)