qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] iotests: handle TypeError for Python3 in test 242
@ 2019-02-22 11:26 Andrey Shinkevich
  2019-02-22 14:53 ` Eric Blake
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Andrey Shinkevich @ 2019-02-22 11:26 UTC (permalink / raw)
  To: qemu-devel, qemu-block
  Cc: eblake, crosa, mreitz, kwolf, ehabkost, philmd, den, vsementsov,
	andrey.shinkevich

The data type for bytes in Python3 differs from the one in Python2.
Those cases should be managed separately.

v1:
In the first version, the TypeError in Python3 was handled as the
exception.
Discussed in the e-mail thread with the Message ID:
<1550519997-253534-1-git-send-email-andrey.shinkevich@virtuozzo.com>

Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reported-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/242 | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
index 16c65ed..446fbf8 100755
--- a/tests/qemu-iotests/242
+++ b/tests/qemu-iotests/242
@@ -20,6 +20,7 @@
 
 import iotests
 import json
+import sys
 from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \
     file_path, img_info_log, log, filter_qemu_io
 
@@ -65,9 +66,12 @@ 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)
+        if sys.version_info.major >= 3:
+            f.write(bytes([toggled]))
+        else:
+            f.write(chr(toggled))
 
 
 qemu_img_create('-f', iotests.imgfmt, disk, '1M')
-- 
1.8.3.1

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

end of thread, other threads:[~2019-02-26 14:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-22 11:26 [Qemu-devel] [PATCH v2] iotests: handle TypeError for Python3 in test 242 Andrey Shinkevich
2019-02-22 14:53 ` Eric Blake
2019-02-25  8:51   ` Andrey Shinkevich
2019-02-22 15:20 ` Cleber Rosa
2019-02-25  8:51   ` Andrey Shinkevich
2019-02-23  9:19 ` Vladimir Sementsov-Ogievskiy
2019-02-25 20:26 ` Eduardo Habkost
2019-02-26  1:42   ` [Qemu-devel] [Qemu-block] " Nir Soffer
2019-02-26 10:39     ` Andrey Shinkevich
2019-02-26 14:06       ` Eric Blake
2019-02-26 14:08         ` Andrey Shinkevich
2019-02-26 10:44     ` Eduardo Habkost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).