[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] iotests: handle TypeError for Python3 in test 2
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [Qemu-devel] [PATCH] iotests: handle TypeError for Python3 in test 242 |
Date: |
Tue, 19 Feb 2019 10:30:23 +0000 |
18.02.2019 22:59, Andrey Shinkevich wrote:
> To write one byte to disk, Python2 may use 'chr' type.
> In Python3, conversion to 'byte' type is required.
>
> Signed-off-by: Andrey Shinkevich <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Forget to say to Andrey that we should add
Reported-by: Kevin Wolf <address@hidden>
> ---
> tests/qemu-iotests/242 | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
> index 16c65ed..6b1f7b8 100755
> --- a/tests/qemu-iotests/242
> +++ b/tests/qemu-iotests/242
> @@ -65,9 +65,14 @@ def toggle_flag(offset):
> with open(disk, "r+b") as f:
> f.seek(offset, 0)
> c = f.read(1)
> - toggled = chr(ord(c) ^ bitmap_flag_unknown)
> + toggled = ord(c) ^ bitmap_flag_unknown
> f.seek(-1, 1)
> - f.write(toggled)
> + try:
> + # python2
> + f.write(chr(toggled))
> + except TypeError:
> + # python3
> + f.write(bytes([toggled]))
>
>
> qemu_img_create('-f', iotests.imgfmt, disk, '1M')
>
--
Best regards,
Vladimir