Write bytes to stderr when raising during system call

libkeyringctl/util.py:
Change `system()` to write bytes to stderr.buffer, as before
CalledProcessError.stdout had been used, which returns a string.
This commit is contained in:
David Runge 2021-10-31 21:20:28 +01:00 committed by Levente Polyak
parent 4597fba6ba
commit a21e6f21fb
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8

View File

@ -105,7 +105,7 @@ def system(cmd: List[str], _stdin: Optional[IO[AnyStr]] = None, exit_on_error: b
try: try:
return check_output(cmd, stderr=STDOUT, stdin=_stdin).decode() return check_output(cmd, stderr=STDOUT, stdin=_stdin).decode()
except CalledProcessError as e: except CalledProcessError as e:
stderr.buffer.write(e.stdout) stderr.buffer.write(bytes(e.stdout, encoding="utf8"))
print_stack() print_stack()
if exit_on_error: if exit_on_error:
exit(e.returncode) exit(e.returncode)