All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>, Nir Soffer <nsoffer@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	Denis Lunev <den@virtuozzo.com>,
	qemu-block <qemu-block@nongnu.org>,
	"philmd@redhat.com" <philmd@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Max Reitz <mreitz@redhat.com>, Cleber Rosa <crosa@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v2] iotests: handle TypeError for Python3 in test 242
Date: Tue, 26 Feb 2019 14:08:36 +0000	[thread overview]
Message-ID: <6b9996ca-3a28-2e5b-ba65-f8239770b6fc@virtuozzo.com> (raw)
In-Reply-To: <d335bcf4-fae8-108d-2e24-9cfba80b5c2c@redhat.com>



On 26/02/2019 17:06, Eric Blake wrote:
> On 2/26/19 4:39 AM, Andrey Shinkevich wrote:
> 
>>>      +++ b/tests/qemu-iotests/242
>>>      @@ -64,10 +64,12 @@ 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)
>>>      +        # The casts to bytearray() below are only necessary
>>>      +        # for Python 2 compatibility
>>>      +        c = bytearray(f.read(1))[0]
>>>
>>>
>>> This is simpler and makes the intent of the code more clear:
>>>
>>>       flag, = struct.unpack("B", f.read(1))
>>>
>>>      +        toggled = c ^ bitmap_flag_unknown
>>>                f.seek(-1, 1)
>>>      -        f.write(toggled)
>>>      +        f.write(bytearray([toggled]))
>>>
>>>
>>> For consistency, we can use struct.pack here:
>>>
>>>       f.write(struct.pack("B", toggled))
>>>
>>> Nir
>>>
>>
>> Thank you all. I am OK with this approach.
>> Will wait for Eric's response.
> 
> That looks better. Peter hasn't applied my pull request yet, so you have
> time to submit a formal v3 (making it easier for me to 'git am' it
> rather than reconstruct from this email), and then I will update my pull
> request to use this improved version.
> 
Noted

-- 
With the best regards,
Andrey Shinkevich


  reply	other threads:[~2019-02-26 14:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2019-02-26 10:44     ` Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6b9996ca-3a28-2e5b-ba65-f8239770b6fc@virtuozzo.com \
    --to=andrey.shinkevich@virtuozzo.com \
    --cc=crosa@redhat.com \
    --cc=den@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=nsoffer@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.