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 <andrey.shinkev...@virtuozzo.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>

Forget to say to Andrey that we should add

Reported-by: Kevin Wolf <kw...@redhat.com>

> ---
>   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

Reply via email to