From nobody Fri Nov 7 18:16:43 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 1548862113147270.37975914312733; Wed, 30 Jan 2019 07:28:33 -0800 (PST) Received: from localhost ([127.0.0.1]:39814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gormx-0000WE-HD for importer@patchew.org; Wed, 30 Jan 2019 10:28:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gorjo-0006b5-Vh for qemu-devel@nongnu.org; Wed, 30 Jan 2019 10:25:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gorjm-0005MJ-UR for qemu-devel@nongnu.org; Wed, 30 Jan 2019 10:25:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37114) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gorjj-0005L4-6A; Wed, 30 Jan 2019 10:25:11 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49DF1C059B77; Wed, 30 Jan 2019 15:25:10 +0000 (UTC) Received: from localhost (unknown [10.40.205.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCE2B5D73F; Wed, 30 Jan 2019 15:25:08 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 30 Jan 2019 16:24:30 +0100 Message-Id: <20190130152434.17283-7-mreitz@redhat.com> In-Reply-To: <20190130152434.17283-1-mreitz@redhat.com> References: <20190130152434.17283-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 30 Jan 2019 15:25:10 +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] [PATCH v2 06/10] iotests.py: Add is_str() 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 , John Snow , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" On Python 2.x, strings are not always unicode strings. This function checks whether a given value is a plain string, or a unicode string (if there is a difference). Signed-off-by: Max Reitz Reviewed-by: John Snow --- tests/qemu-iotests/iotests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index f51456fa63..3e91444b79 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -221,6 +221,12 @@ def image_size(img): r =3D qemu_img_pipe('info', '--output=3Djson', '-f', imgfmt, img) return json.loads(r)['virtual-size'] =20 +def is_str(val): + if sys.version_info.major >=3D 3: + return isinstance(val, str) + else: + return isinstance(val, str) or isinstance(val, unicode) + test_dir_re =3D re.compile(r"%s" % test_dir) def filter_test_dir(msg): return test_dir_re.sub("TEST_DIR", msg) --=20 2.20.1