Skip to content

Commit e336cec

Browse files
committed
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 <[email protected]> Message-Id: <[email protected]>
1 parent 2667e06 commit e336cec

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/docker/docker.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import re
2525
import signal
2626
from tarfile import TarFile, TarInfo
27-
from io import StringIO
27+
from io import StringIO, BytesIO
2828
from shutil import copy, rmtree
2929
from pwd import getpwuid
3030
from datetime import datetime, timedelta
@@ -541,13 +541,14 @@ def run(self, args, argv):
541541

542542
# Create a Docker buildfile
543543
df = StringIO()
544-
df.write("FROM %s\n" % args.tag)
545-
df.write("ADD . /\n")
546-
df.seek(0)
544+
df.write(u"FROM %s\n" % args.tag)
545+
df.write(u"ADD . /\n")
546+
547+
df_bytes = BytesIO(bytes(df.getvalue(), "UTF-8"))
547548

548549
df_tar = TarInfo(name="Dockerfile")
549-
df_tar.size = len(df.buf)
550-
tmp_tar.addfile(df_tar, fileobj=df)
550+
df_tar.size = df_bytes.getbuffer().nbytes
551+
tmp_tar.addfile(df_tar, fileobj=df_bytes)
551552

552553
tmp_tar.close()
553554

0 commit comments

Comments
 (0)