* [Qemu-devel] [PATCH v3] iotests: handle TypeError for Python 3 in test 242
@ 2019-02-26 16:11 Andrey Shinkevich
2019-02-26 16:35 ` Eric Blake
0 siblings, 1 reply; 5+ messages in thread
From: Andrey Shinkevich @ 2019-02-26 16:11 UTC (permalink / raw)
To: qemu-devel, qemu-block
Cc: eblake, nsoffer, mreitz, kwolf, ehabkost, den, vsementsov,
andrey.shinkevich
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: Nir Soffer <nsoffer@redhat.com>
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reported-by: Kevin Wolf <kwolf@redhat.com>
---
v2:
The TypeError in Python 3 was handled based on the version check.
Discussed in the e-mail thread with the Message ID:
<1550834773-873512-1-git-send-email-andrey.shinkevich@virtuozzo.com>
v1:
The TypeError in Python 3 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>
tests/qemu-iotests/242 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
index 16c65ed..c176e92 100755
--- a/tests/qemu-iotests/242
+++ b/tests/qemu-iotests/242
@@ -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')
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [Qemu-devel] [PATCH v3] iotests: handle TypeError for Python 3 in test 242
2019-02-26 16:11 [Qemu-devel] [PATCH v3] iotests: handle TypeError for Python 3 in test 242 Andrey Shinkevich
@ 2019-02-26 16:35 ` Eric Blake
2019-02-26 16:42 ` Andrey Shinkevich
0 siblings, 1 reply; 5+ messages in thread
From: Eric Blake @ 2019-02-26 16:35 UTC (permalink / raw)
To: Andrey Shinkevich, qemu-devel, qemu-block
Cc: nsoffer, mreitz, kwolf, ehabkost, den, vsementsov
On 2/26/19 10:11 AM, Andrey Shinkevich wrote:
> 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: Nir Soffer <nsoffer@redhat.com>
> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> ---
Reviewed-by: Eric Blake <eblake@redhat.com>
Will include this in my v2 pull request.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v3] iotests: handle TypeError for Python 3 in test 242
2019-02-26 16:35 ` Eric Blake
@ 2019-02-26 16:42 ` Andrey Shinkevich
0 siblings, 0 replies; 5+ messages in thread
From: Andrey Shinkevich @ 2019-02-26 16:42 UTC (permalink / raw)
To: Eric Blake, qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: nsoffer@redhat.com, mreitz@redhat.com, kwolf@redhat.com,
ehabkost@redhat.com, Denis Lunev, Vladimir Sementsov-Ogievskiy
On 26/02/2019 19:35, Eric Blake wrote:
> On 2/26/19 10:11 AM, Andrey Shinkevich wrote:
>> 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: Nir Soffer <nsoffer@redhat.com>
>> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>> ---
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
> Will include this in my v2 pull request.
>
Sounds good!
--
With the best regards,
Andrey Shinkevich
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v3] iotests: handle TypeError for Python 3 in test 242
@ 2019-02-26 15:53 Andrey Shinkevich
2019-02-26 16:14 ` Andrey Shinkevich
0 siblings, 1 reply; 5+ messages in thread
From: Andrey Shinkevich @ 2019-02-26 15:53 UTC (permalink / raw)
To: qemu-devel, qemu-block
Cc: eblake, nsoffer, mreitz, kwolf, ehabkost, den, vsementsov,
andrey.shinkevich
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: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reported-by: Kevin Wolf <kwolf@redhat.com>
---
v2:
The TypeError in Python3 was handled based on the version check.
Discussed in the e-mail thread with the Message ID:
<1550834773-873512-1-git-send-email-andrey.shinkevich@virtuozzo.com>
v1:
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>
tests/qemu-iotests/242 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
index 16c65ed..c176e92 100755
--- a/tests/qemu-iotests/242
+++ b/tests/qemu-iotests/242
@@ -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')
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [Qemu-devel] [PATCH v3] iotests: handle TypeError for Python 3 in test 242
2019-02-26 15:53 Andrey Shinkevich
@ 2019-02-26 16:14 ` Andrey Shinkevich
0 siblings, 0 replies; 5+ messages in thread
From: Andrey Shinkevich @ 2019-02-26 16:14 UTC (permalink / raw)
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: eblake@redhat.com, nsoffer@redhat.com, mreitz@redhat.com,
kwolf@redhat.com, ehabkost@redhat.com, Denis Lunev,
Vladimir Sementsov-Ogievskiy
Sorry about the missed 'Signed-off-by: Nir Soffer <nsoffer@redhat.com>'
The patch has been resent.
On 26/02/2019 18:53, Andrey Shinkevich wrote:
> 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: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> ---
> v2:
> The TypeError in Python3 was handled based on the version check.
> Discussed in the e-mail thread with the Message ID:
> <1550834773-873512-1-git-send-email-andrey.shinkevich@virtuozzo.com>
>
> v1:
> 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>
>
> tests/qemu-iotests/242 | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
> index 16c65ed..c176e92 100755
> --- a/tests/qemu-iotests/242
> +++ b/tests/qemu-iotests/242
> @@ -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')
>
--
With the best regards,
Andrey Shinkevich
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-02-26 16:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-26 16:11 [Qemu-devel] [PATCH v3] iotests: handle TypeError for Python 3 in test 242 Andrey Shinkevich
2019-02-26 16:35 ` Eric Blake
2019-02-26 16:42 ` Andrey Shinkevich
-- strict thread matches above, loose matches on Subject: below --
2019-02-26 15:53 Andrey Shinkevich
2019-02-26 16:14 ` Andrey Shinkevich
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).