From nobody Fri May 17 04:49:47 2024 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=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155083490322182.97882751643897; Fri, 22 Feb 2019 03:28:23 -0800 (PST) Received: from localhost ([127.0.0.1]:48899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gx90A-0000SQ-AL for importer@patchew.org; Fri, 22 Feb 2019 06:28:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gx8z5-0008Nb-3w for qemu-devel@nongnu.org; Fri, 22 Feb 2019 06:27:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gx8z4-0000l8-80 for qemu-devel@nongnu.org; Fri, 22 Feb 2019 06:27:15 -0500 Received: from relay.sw.ru ([185.231.240.75]:55554) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gx8z3-0008IM-NH; Fri, 22 Feb 2019 06:27:14 -0500 Received: from [172.16.25.136] (helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gx8y5-0006Nz-Sm; Fri, 22 Feb 2019 14:26:13 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 22 Feb 2019 14:26:13 +0300 Message-Id: <1550834773-873512-1-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2] iotests: handle TypeError for Python3 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: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, mreitz@redhat.com, andrey.shinkevich@virtuozzo.com, crosa@redhat.com, den@openvz.org, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reported-by: Kevin Wolf Reviewed-by: Cleber Rosa Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- 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 @@ =20 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 =20 @@ -65,9 +66,12 @@ 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) + toggled =3D ord(c) ^ bitmap_flag_unknown f.seek(-1, 1) - f.write(toggled) + if sys.version_info.major >=3D 3: + f.write(bytes([toggled])) + else: + f.write(chr(toggled)) =20 =20 qemu_img_create('-f', iotests.imgfmt, disk, '1M') --=20 1.8.3.1