|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v20210701 06/40] tools: fix Python3.4 TypeError in format string
On Thu, Jul 01, 2021 at 11:56:01AM +0200, Olaf Hering wrote:
> 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.
> Use a syntax that is handled by all three variants.
>
> Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
> ---
> 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 9003ac4f6d..235b922ff5 100755
> --- a/tools/python/scripts/convert-legacy-stream
> +++ b/tools/python/scripts/convert-legacy-stream
> @@ -347,9 +347,9 @@ def read_libxl_toolstack(vm, data):
> if nil != 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 = bytes(("physmap/%x" % phys).encode('utf-8'))
> + kv = [root + b"/start_addr", bytes(("%x" % start).encode('utf-8')),
> + root + b"/size", bytes(("%x" % size).encode('utf-8')),
Why bytes()? Encode does already return bytes type.
> root + b"/name", name]
>
> for key, val in zip(kv[0::2], kv[1::2]):
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
Attachment:
signature.asc
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |