summaryrefslogtreecommitdiffstats
path: root/tests/docker
diff options
context:
space:
mode:
authorAlex Bennée2020-07-24 08:45:02 +0200
committerAlex Bennée2020-07-27 10:41:18 +0200
commite336cec3a59df5c4e79f6f9625780dccd8a607db (patch)
treecc94fa1db343ea0c4368970811a7f23a12b7cab6 /tests/docker
parentlinux-user: don't use MAP_FIXED in pgd_find_hole_fallback (diff)
downloadqemu-e336cec3a59df5c4e79f6f9625780dccd8a607db.tar.gz
qemu-e336cec3a59df5c4e79f6f9625780dccd8a607db.tar.xz
qemu-e336cec3a59df5c4e79f6f9625780dccd8a607db.zip
tests/docker: fix update command due to python3 str/bytes distinction
Does this seem convoluted to you? It feels a little complicated to me. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20200724064509.331-10-alex.bennee@linaro.org>
Diffstat (limited to 'tests/docker')
-rwxr-xr-xtests/docker/docker.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index c9f20d8d09..356d7618f1 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()