From patchwork Mon Feb 18 19:59:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Shinkevich X-Patchwork-Id: 10818795 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC023139A for ; Mon, 18 Feb 2019 20:00:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C96892B81C for ; Mon, 18 Feb 2019 20:00:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDD0B2BA75; Mon, 18 Feb 2019 20:00:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C3F622B81C for ; Mon, 18 Feb 2019 20:00:50 +0000 (UTC) Received: from localhost ([127.0.0.1]:35963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvp5t-0006cE-OX for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Feb 2019 15:00:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvp58-0006Gm-4I for qemu-devel@nongnu.org; Mon, 18 Feb 2019 15:00:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvp57-0007am-Ci for qemu-devel@nongnu.org; Mon, 18 Feb 2019 15:00:02 -0500 Received: from relay.sw.ru ([185.231.240.75]:55552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvp57-0007Z8-4k; Mon, 18 Feb 2019 15:00:01 -0500 Received: from [172.16.25.136] (helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gvp53-0003Up-L7; Mon, 18 Feb 2019 22:59:57 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 18 Feb 2019 22:59:57 +0300 Message-Id: <1550519997-253534-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] 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, mreitz@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP To write one byte to disk, Python2 may use 'chr' type. In Python3, conversion to 'byte' type is required. Signed-off-by: Andrey Shinkevich Acked-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Reported-by: Kevin Wolf --- tests/qemu-iotests/242 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242 index 16c65ed..6b1f7b8 100755 --- a/tests/qemu-iotests/242 +++ b/tests/qemu-iotests/242 @@ -65,9 +65,14 @@ 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) + try: + # python2 + f.write(chr(toggled)) + except TypeError: + # python3 + f.write(bytes([toggled])) qemu_img_create('-f', iotests.imgfmt, disk, '1M')