From 8eb5e6746feaf9e021b69ea2521899f8dc889033 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Mon, 22 Oct 2018 14:53:01 +0100 Subject: iotests: Use Python byte strings where appropriate Since byte strings are no longer the default in Python 3, we have to explicitly use them where we need to, which is mostly when working with structures. It also means that we need to open a file in binary mode when we want to use structures. On the other hand, we have to accomodate for the fact that some functions (still) work with byte strings but we want to use unicode strings (in Python 3 at least, and it does not matter in Python 2). This includes base64 encoding, but it is most notable when working with the subprocess module: Either we set universal_newlines to True so that the default streams are opened in text mode (hence this parameter is aliased as "text" as of 3.7), or, if that is not possible, we have to decode the output to a normal string. Signed-off-by: Max Reitz Reviewed-by: Eduardo Habkost Message-Id: <20181022135307.14398-4-mreitz@redhat.com> Signed-off-by: Eduardo Habkost --- scripts/qtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/qtest.py b/scripts/qtest.py index df0daf26ca..adf1fe3f26 100644 --- a/scripts/qtest.py +++ b/scripts/qtest.py @@ -64,7 +64,7 @@ class QEMUQtestProtocol(object): @param qtest_cmd: qtest command text to be sent """ - self._sock.sendall(qtest_cmd + "\n") + self._sock.sendall((qtest_cmd + "\n").encode('utf-8')) def close(self): self._sock.close() -- cgit v1.2.3