diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2023-11-17 15:30:05 +0530 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2023-11-17 13:00:46 +0000 |
commit | 651c103f3a43d82588388b1191285c99aed4c42d (patch) | |
tree | e3a7d307c406cde9389bb747cbe51dea70e98b03 | |
parent | 323963f4ccac767fbc322a0cc850dec84feac76e (diff) |
cerbero: Fix exception when handling CalledProcessError
The 'output' param can be str or bytes depending on the python
version, so handle both separately.
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1307>
-rw-r--r-- | cerbero/utils/shell.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/cerbero/utils/shell.py b/cerbero/utils/shell.py index d37d410b..4e31464a 100644 --- a/cerbero/utils/shell.py +++ b/cerbero/utils/shell.py @@ -171,7 +171,9 @@ def check_output(cmd, cmd_dir=None, fail=True, logfile=None, env=None, quiet=Fal try: o = subprocess.check_output(cmd, cwd=cmd_dir, env=env, stderr=stderr) except SUBPROCESS_EXCEPTIONS as e: - msg = getattr(e, 'output', '').decode(sys.stdout.encoding, errors='replace') + msg = getattr(e, 'output', '') + if isinstance(msg, bytes): + msg = msg.decode(sys.stdout.encoding, errors='replace') if not fail: return msg if logfile: |