From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:54330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsqYq-0003JC-Dc for qemu-devel@nongnu.org; Sun, 10 Feb 2019 09:58:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gsqYm-000687-MM for qemu-devel@nongnu.org; Sun, 10 Feb 2019 09:58:22 -0500 From: Max Reitz Date: Sun, 10 Feb 2019 15:57:32 +0100 Message-Id: <20190210145736.1486-7-mreitz@redhat.com> In-Reply-To: <20190210145736.1486-1-mreitz@redhat.com> References: <20190210145736.1486-1-mreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v3 06/10] iotests.py: Add is_str() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Max Reitz , John Snow , Kevin Wolf 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.p= y index 82dd096c6e..52fc77563c 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -236,6 +236,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