From nobody Sun Oct 5 19:22:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15511999678961023.8756799169114; Tue, 26 Feb 2019 08:52:47 -0800 (PST) Received: from localhost ([127.0.0.1]:58191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyfyE-0000mE-Mi for importer@patchew.org; Tue, 26 Feb 2019 11:52:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyfw0-0007zH-3u for qemu-devel@nongnu.org; Tue, 26 Feb 2019 11:50:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyfvw-0001Uo-9R for qemu-devel@nongnu.org; Tue, 26 Feb 2019 11:50:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43259) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gyfvt-0001Ry-EX; Tue, 26 Feb 2019 11:50:18 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF722C05D3F8; Tue, 26 Feb 2019 16:50:16 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-222.phx2.redhat.com [10.3.116.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BBA228D29; Tue, 26 Feb 2019 16:50:15 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 26 Feb 2019 10:50:11 -0600 Message-Id: <20190226165013.24867-2-eblake@redhat.com> In-Reply-To: <20190226165013.24867-1-eblake@redhat.com> References: <20190226165013.24867-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 26 Feb 2019 16:50:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 1/3] iotests: handle TypeError for Python 3 in test 242 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nir Soffer , Andrey Shinkevich , "open list:Block layer core" , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: 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 Signed-off-by: Andrey Shinkevich Reported-by: Kevin Wolf Message-Id: <1551197495-24425-1-git-send-email-andrey.shinkevich@virtuozzo.= com> Reviewed-by: Eric Blake Signed-off-by: Eric Blake --- 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 16c65edcd7f..c176e92da6a 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 =3D f.read(1) - toggled =3D chr(ord(c) ^ bitmap_flag_unknown) + # Read one byte in a way compatible with Python 2 + flags =3D struct.unpack("B", f.read(1)) + toggled =3D 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') --=20 2.20.1