From 7f50d2b57fa7a2a6092d2ea3c3c1eb9d76de800a Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 18 May 2021 15:39:01 +0000 Subject: [PATCH] buildroot: don't specify encoding for popen Since low-level primitives (os.read) are used to read from the stdout pipe, manual text decoding was necessary there anyway. The `encoding` argument meant that we could forgo the manual decoding for the call to `communicate`. But this meant that text handling is not uniform. Therefore, remove the `encoding` argument from the `Popen` call and manual decode all the text. --- osbuild/buildroot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osbuild/buildroot.py b/osbuild/buildroot.py index b23980c9..e4c89ac3 100644 --- a/osbuild/buildroot.py +++ b/osbuild/buildroot.py @@ -235,7 +235,6 @@ class BuildRoot(contextlib.AbstractContextManager): stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - encoding="utf-8", close_fds=True) data = io.StringIO() @@ -250,7 +249,8 @@ class BuildRoot(contextlib.AbstractContextManager): data.write(txt) monitor.log(txt) - txt, _ = proc.communicate() + buf, _ = proc.communicate() + txt = buf.decode("utf-8") monitor.log(txt) data.write(txt) output = data.getvalue()