From nobody Mon Feb 9 09:34:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540216980654527.1167806031787; Mon, 22 Oct 2018 07:03:00 -0700 (PDT) Received: from localhost ([::1]:35433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEanG-0002Ju-1A for importer@patchew.org; Mon, 22 Oct 2018 10:02:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEaeb-0003ti-Ms for qemu-devel@nongnu.org; Mon, 22 Oct 2018 09:53:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEaea-0006O1-Cr for qemu-devel@nongnu.org; Mon, 22 Oct 2018 09:53:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60662) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEaeX-0006HE-BQ; Mon, 22 Oct 2018 09:53:53 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D32E2027A; Mon, 22 Oct 2018 13:53:48 +0000 (UTC) Received: from localhost (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF360608F3; Mon, 22 Oct 2018 13:53:47 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 22 Oct 2018 14:53:06 +0100 Message-Id: <20181022135307.14398-9-mreitz@redhat.com> In-Reply-To: <20181022135307.14398-1-mreitz@redhat.com> References: <20181022135307.14398-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 22 Oct 2018 13:53:48 +0000 (UTC) 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] [PATCH v3 8/9] iotests: Modify imports for Python 3 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: Kevin Wolf , Cleber Rosa , qemu-devel@nongnu.org, Eduardo Habkost , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There are two imports that need to be modified when running the iotests under Python 3: One is StringIO, which no longer exists; instead, the StringIO class comes from the io module, so import it from there (and use the BytesIO class for Python 2). The other is the ConfigParser, which has just been renamed to configparser. Signed-off-by: Max Reitz Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- tests/qemu-iotests/iotests.py | 13 +++++++++---- tests/qemu-iotests/nbd-fault-injector.py | 7 +++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 7ca94e9278..a0f35e4b68 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -29,6 +29,7 @@ import json import signal import logging import atexit +import io =20 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'scrip= ts')) import qtest @@ -681,15 +682,19 @@ def main(supported_fmts=3D[], supported_oses=3D['linu= x'], supported_cache_modes=3D[], verify_platform(supported_oses) verify_cache_mode(supported_cache_modes) =20 - # We need to filter out the time taken from the output so that qemu-io= test - # can reliably diff the results against master output. - import StringIO if debug: output =3D sys.stdout verbosity =3D 2 sys.argv.remove('-d') else: - output =3D StringIO.StringIO() + # We need to filter out the time taken from the output so that + # qemu-iotest can reliably diff the results against master output. + if sys.version_info.major >=3D 3: + output =3D io.StringIO() + else: + # io.StringIO is for unicode strings, which is not what + # 2.x's test runner emits. + output =3D io.BytesIO() =20 logging.basicConfig(level=3D(logging.DEBUG if debug else logging.WARN)) =20 diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/= nbd-fault-injector.py index d45e2e0a6a..6b2d659dee 100755 --- a/tests/qemu-iotests/nbd-fault-injector.py +++ b/tests/qemu-iotests/nbd-fault-injector.py @@ -48,7 +48,10 @@ import sys import socket import struct import collections -import ConfigParser +if sys.version_info.major >=3D 3: + import configparser +else: + import ConfigParser as configparser =20 FAKE_DISK_SIZE =3D 8 * 1024 * 1024 * 1024 # 8 GB =20 @@ -225,7 +228,7 @@ def parse_config(config): return rules =20 def load_rules(filename): - config =3D ConfigParser.RawConfigParser() + config =3D configparser.RawConfigParser() with open(filename, 'rt') as f: config.readfp(f, filename) return parse_config(config) --=20 2.17.1