All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] iotests: handle TypeError for Python3 in test 242
@ 2019-02-18 19:59 Andrey Shinkevich
  2019-02-18 20:05 ` Eric Blake
  2019-02-19 10:30 ` Vladimir Sementsov-Ogievskiy
  0 siblings, 2 replies; 6+ messages in thread
From: Andrey Shinkevich @ 2019-02-18 19:59 UTC (permalink / raw)
  To: qemu-devel, qemu-block
  Cc: eblake, mreitz, kwolf, den, vsementsov, andrey.shinkevich

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.shinkevich@virtuozzo.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')
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-02-22  9:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-18 19:59 [Qemu-devel] [PATCH] iotests: handle TypeError for Python3 in test 242 Andrey Shinkevich
2019-02-18 20:05 ` Eric Blake
2019-02-18 21:25   ` Philippe Mathieu-Daudé
2019-02-22  0:17     ` Cleber Rosa
2019-02-22  9:48       ` Andrey Shinkevich
2019-02-19 10:30 ` Vladimir Sementsov-Ogievskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.