[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/5] tools/python: fix Python3.4 TypeError in format string


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 5 Jul 2021 20:10:24 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Olaf Hering <olaf@xxxxxxxxx>, "Juergen Gross" <jgross@xxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 05 Jul 2021 19:11:06 +0000
  • Ironport-hdrordr: A9a23:VSWnXau4mLbJk92XYmB6z5J97skDYNV00zEX/kB9WHVpmszxra 6TdZUgpHjJYVkqOE3I9ertBEDiewK5yXcW2/hzAV7KZmCP0wHEEGgL1/qG/9SKIUzDH4Bmup uIC5IOauHNMQ==
  • Ironport-sdr: 1c9I/CO3mklO3t3Sj43l5AUhdN1jpqz8bljjxBwAjER/X9xEmVrm9EAnunhK2rtWehTTOlpmz7 qB0jhsGU9KX+LIG9F4Vq3dxTAxoOk5mYtl79W/x8D2xpBE7odoEUpzNW4hfWFC8PM+USWwDeOD SLM7eMei7L4pc9+r3t2LHyn+44BWChEfBGSGHDDh0CVJoIq83i7yoSCtN0Is6TiSduyOLC+Xzp dZeP1NobtXmrAmwLqhBRpMN1jZGYHa91STJzeHNpnNYkZB6o4oJdlJW7Z+RdJKHeoIwSNR5DgX 1p8=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Olaf Hering <olaf@xxxxxxxxx>

Using the first element of a tuple for a format specifier fails with
python3.4 as included in SLE12:
    b = b"string/%x" % (i, )
TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'

It happens to work with python 2.7 and 3.6.
To support older Py3, format as strings and explicitly encode as ASCII.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 tools/python/scripts/convert-legacy-stream | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/python/scripts/convert-legacy-stream 
b/tools/python/scripts/convert-legacy-stream
index 227e1b5c3fd3..7fe375a66810 100755
--- a/tools/python/scripts/convert-legacy-stream
+++ b/tools/python/scripts/convert-legacy-stream
@@ -346,9 +346,9 @@ def read_libxl_toolstack(vm, data):
         if bytearray(name)[-1] != 0:
             raise StreamError("physmap name not NUL terminated")
 
-        root = b"physmap/%x" % (phys, )
-        kv = [root + b"/start_addr", b"%x" % (start, ),
-              root + b"/size",       b"%x" % (size, ),
+        root = ("physmap/%x" % (phys, )).encode('ascii')
+        kv = [root + b"/start_addr", ("%x" % (start, )).encode('ascii'),
+              root + b"/size",       ("%x" % (size, )).encode('ascii'),
               root + b"/name",       name[:-1]]
 
         for key, val in zip(kv[0::2], kv[1::2]):
-- 
2.11.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.