From nobody Sun May 5 19:15:08 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153195347827272.7991569336175; Wed, 18 Jul 2018 15:37:58 -0700 (PDT) Received: from localhost ([::1]:38535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffv4z-0007xO-Q0 for importer@patchew.org; Wed, 18 Jul 2018 18:37:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffv3u-0007NK-Em for qemu-devel@nongnu.org; Wed, 18 Jul 2018 18:36:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffv3q-0007Yg-72 for qemu-devel@nongnu.org; Wed, 18 Jul 2018 18:36:46 -0400 Received: from mail-vk0-x230.google.com ([2607:f8b0:400c:c05::230]:33146) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffv3q-0007YL-0v; Wed, 18 Jul 2018 18:36:42 -0400 Received: by mail-vk0-x230.google.com with SMTP id y70-v6so3390835vkc.0; Wed, 18 Jul 2018 15:36:41 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id 14-v6sm1393108vkh.28.2018.07.18.15.36.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 15:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Xvf/4oDqEULgpUf7xcg3hYgriAuVsJFcjstfGwQl9/c=; b=DZmX95H55Q8X5Fe9KX3p100geH886PXH9weFJC2zyZ58q6exeRabOD2St2oDaBzEgy CcKmF8aC+D6hrZ6J3A6iknEu3Ig/EJ0oYk8f2XLlZ1mDHF37mg7BlBZNXSmpDit8GRUc 9Aphr9dbcPXkfp4DJbhYeCAv5j6j6/bfaUbC7TODOAfrvbXTIqf2Mql6xk2CGTVhZHAy ZmTPA4mIjGdbrvYlQTWJi276nkgpN4ekjDD54s6wPKmV5KiXmdP0wNbAg17+mKeIpY0S +pk7Dj6NicgnpczgM8qO7SoBtw9mPctrYvJX+EZzErNihaNJpP276ozYQFEp78L4Sjan 5tzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=Xvf/4oDqEULgpUf7xcg3hYgriAuVsJFcjstfGwQl9/c=; b=Nu/VmJP6ccpepY2+kYuC5gwIhTh58uIQ26JyJ8k+4cUElQacI3zOgkd63cUpndBpHI SNdFe4HxI/Lm3s1XfTZBgckiG+toSo2OjdCDtln7QhbbKh36pI4mFMG81O9dWk90Gr7M UWs+ta6UkVRu9MkJr68l954SxZ3uKodJavdfumgs2RxzOYwbuwUtfPNYfSCfCEoXO4tc GqQm7TYHzciDKdyDgKV+cPXIVQ+ssbRuot00U1lEzg2b1k+2LkXR4zpsyz15LExEpSur 3IxvYkF5UvXHq8Uvv8gEY20y361pmp0Xuh6MaDwvyFyuZboiui6ELWdjVb/283x2B0DD 7iYQ== X-Gm-Message-State: AOUpUlGyD8Qp4NN/tPjjR8Fo5v63oghi1fzDVdhmxQTcfUF6LPSWQSg1 ZejDxrHDMzN2ZrVR1t3modI= X-Google-Smtp-Source: AAOMgpep0IrpAR2S0FdhD3brBmYhyjvj7gbnf7BzzA0urg1Gh5lIUlgAVRJIDwtEewvvnqhYKralFw== X-Received: by 2002:a1f:3cc5:: with SMTP id j188-v6mr4471917vka.156.1531953401366; Wed, 18 Jul 2018 15:36:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Fam Zheng , Kevin Wolf , Max Reitz , Eduardo Habkost , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Daniel P . Berrange" Date: Wed, 18 Jul 2018 19:36:28 -0300 Message-Id: <20180718223628.5062-1-f4bug@amsat.org> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c05::230 Subject: [Qemu-devel] [PATCH for-3.1 v2] python: Use io.StringIO 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: Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Both Python 2.7 and 3 support the same io.StringIO to handle unicode strings. Python 2.6 requires special care, but since 7f2b55443a his support was removed. Stop caring, drop the ImportError check. Use the common form to use indistinctly Python 2.7 or 3. http://python-future.org/compatible_idioms.html#stringio This fixes running tests on the Fedora Docker image, which uses Python3 since 356dc290f: $ make docker-test-block@fedora [...] 045 [failed, exit status 1] - output mismatch (see 045.out.bad) --- /tmp/qemu-test/src/tests/qemu-iotests/045.out 2018-07-17 16:56:= 18.000000000 +0000 +++ /tmp/qemu-test/build/tests/qemu-iotests/045.out.bad 2018-07-17 17:19:= 22.448409007 +0000 @@ -1,5 +1,6 @@ -........... ----------------------------------------------------------------------- -Ran 11 tests - -OK +Traceback (most recent call last): + File "045", line 178, in + iotests.main(supported_fmts=3D['raw']) + File "/tmp/qemu-test/src/tests/qemu-iotests/iotests.py", line 682, in = main + import StringIO +ModuleNotFoundError: No module named 'StringIO' 132 [failed, exit status 1] - output mismatch (see 132.out.bad) 152 [failed, exit status 1] - output mismatch (see 152.out.bad) Failures: 045 132 152 Suggested-by: Eduardo Habkost Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/docker/docker.py | 5 +---- tests/image-fuzzer/runner.py | 6 +++--- tests/qemu-iotests/iotests.py | 5 +++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 69e7130db7..9d53b868db 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -26,10 +26,7 @@ import tempfile import re import signal from tarfile import TarFile, TarInfo -try: - from StringIO import StringIO -except ImportError: - from io import StringIO +from io import StringIO from shutil import copy, rmtree from pwd import getpwuid from datetime import datetime,timedelta diff --git a/tests/image-fuzzer/runner.py b/tests/image-fuzzer/runner.py index 95d84f38f3..4462d84f45 100755 --- a/tests/image-fuzzer/runner.py +++ b/tests/image-fuzzer/runner.py @@ -28,7 +28,7 @@ import shutil from itertools import count import time import getopt -import StringIO +from io import StringIO import resource =20 try: @@ -183,7 +183,7 @@ class TestEnv(object): MAX_BACKING_FILE_SIZE) * (1 << = 20) cmd =3D self.qemu_img + ['create', '-f', backing_file_fmt, backing_file_name, str(backing_file_size)] - temp_log =3D StringIO.StringIO() + temp_log =3D StringIO() retcode =3D run_app(temp_log, cmd) if retcode =3D=3D 0: temp_log.close() @@ -240,7 +240,7 @@ class TestEnv(object): "Backing file: %s\n" \ % (self.seed, " ".join(current_cmd), self.current_dir, backing_file_name) - temp_log =3D StringIO.StringIO() + temp_log =3D StringIO() try: retcode =3D run_app(temp_log, current_cmd) except OSError as e: diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 4e67fbbe96..c95dd17190 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -679,13 +679,14 @@ def main(supported_fmts=3D[], supported_oses=3D['linu= x'], supported_cache_modes=3D[], =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 + from io import StringIO + if debug: output =3D sys.stdout verbosity =3D 2 sys.argv.remove('-d') else: - output =3D StringIO.StringIO() + output =3D StringIO() =20 logging.basicConfig(level=3D(logging.DEBUG if debug else logging.WARN)) =20 --=20 2.18.0