提交 42eb4591 编写于 作者: A Andrey Shinkevich 提交者: Eric Blake

iotests: handle TypeError for Python 3 in test 242

The data type for bytes in Python 3 differs from the one in Python 2.
The type cast that is compatible with both versions was applied.
Signed-off-by: NNir Soffer <nsoffer@redhat.com>
Signed-off-by: NAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reported-by: NKevin Wolf <kwolf@redhat.com>
Message-Id: <1551197495-24425-1-git-send-email-andrey.shinkevich@virtuozzo.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 d88d85f1
......@@ -20,6 +20,7 @@
import iotests
import json
import struct
from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \
file_path, img_info_log, log, filter_qemu_io
......@@ -64,10 +65,11 @@ def write_to_disk(offset, size):
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)
# Read one byte in a way compatible with Python 2
flags = struct.unpack("B", f.read(1))
toggled = flags[0] ^ bitmap_flag_unknown
f.seek(-1, 1)
f.write(toggled)
f.write(struct.pack("B", toggled))
qemu_img_create('-f', iotests.imgfmt, disk, '1M')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册