[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/12] tests/docker: fix update command due to python3 str/byt
From: |
Alex Bennée |
Subject: |
[PATCH v2 09/12] tests/docker: fix update command due to python3 str/bytes distinction |
Date: |
Wed, 22 Jul 2020 07:28:59 +0100 |
Does this seem convoluted to you? It feels a little complicated to me.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tests/docker/docker.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index c9f20d8d093..356d7618f1a 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -24,7 +24,7 @@ import tempfile
import re
import signal
from tarfile import TarFile, TarInfo
-from io import StringIO
+from io import StringIO, BytesIO
from shutil import copy, rmtree
from pwd import getpwuid
from datetime import datetime, timedelta
@@ -541,13 +541,14 @@ class UpdateCommand(SubCommand):
# Create a Docker buildfile
df = StringIO()
- df.write("FROM %s\n" % args.tag)
- df.write("ADD . /\n")
- df.seek(0)
+ df.write(u"FROM %s\n" % args.tag)
+ df.write(u"ADD . /\n")
+
+ df_bytes = BytesIO(bytes(df.getvalue(), "UTF-8"))
df_tar = TarInfo(name="Dockerfile")
- df_tar.size = len(df.buf)
- tmp_tar.addfile(df_tar, fileobj=df)
+ df_tar.size = df_bytes.getbuffer().nbytes
+ tmp_tar.addfile(df_tar, fileobj=df_bytes)
tmp_tar.close()
--
2.20.1
[PATCH v2 08/12] linux-user: don't use MAP_FIXED in pgd_find_hole_fallback, Alex Bennée, 2020/07/22
[PATCH v2 09/12] tests/docker: fix update command due to python3 str/bytes distinction,
Alex Bennée <=
[PATCH v2 10/12] tests/docker: fix binfmt_misc image building, Alex Bennée, 2020/07/22
[PATCH v2 07/12] target/i386: floatx80: avoid compound literals in static initializers, Alex Bennée, 2020/07/22
[PATCH v2 12/12] linux-user: fix clock_nanosleep(), Alex Bennée, 2020/07/22
Re: [PATCH v2 12/12] linux-user: fix clock_nanosleep(), Philippe Mathieu-Daudé, 2020/07/22