From 217183405a6175142c11b121eb9412d5800e4c4a Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Fri, 26 Jan 2018 13:06:21 +0100 Subject: [PATCH] Decode git call output in Python 3 The subprocess communicate() method returns byte streams for stdout and stderr in Python 3. They need to be decoded to str. Otherwise the version string parsing will fail: Traceback (most recent call last): File "salt/version.py", line 522, in __discover_version return SaltStackVersion.parse(out) File "salt/version.py", line 267, in parse 'Unable to parse version string: \'{0}\''.format(version_string) ValueError: Unable to parse version string: 'b'c0e6782d'' --- salt/version.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/salt/version.py b/salt/version.py index 6e5d4e74af..741d59ce25 100644 --- a/salt/version.py +++ b/salt/version.py @@ -512,6 +512,9 @@ def __discover_version(saltstack_version): process = subprocess.Popen( ['git', 'describe', '--tags', '--match', 'v[0-9]*', '--always'], **kwargs) out, err = process.communicate() + if six.PY3: + out = out.decode() + err = err.decode() out = out.strip() err = err.strip()