From nobody Tue Nov 4 15:28:05 2025 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530065872830883.8326852995541; Tue, 26 Jun 2018 19:17:52 -0700 (PDT) Received: from localhost ([::1]:56137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fY01i-0008QO-Ok for importer@patchew.org; Tue, 26 Jun 2018 22:17:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXzzM-0007FW-NU for qemu-devel@nongnu.org; Tue, 26 Jun 2018 22:15:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXzzH-0002en-Nk for qemu-devel@nongnu.org; Tue, 26 Jun 2018 22:15:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fXzzH-0002e4-IO for qemu-devel@nongnu.org; Tue, 26 Jun 2018 22:15:15 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D4BE3C057F4E; Wed, 27 Jun 2018 02:15:14 +0000 (UTC) Received: from localhost (ovpn-116-35.gru2.redhat.com [10.97.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8977DB74DD; Wed, 27 Jun 2018 02:15:02 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 23:14:22 -0300 Message-Id: <20180627021423.18404-6-ehabkost@redhat.com> In-Reply-To: <20180627021423.18404-1-ehabkost@redhat.com> References: <20180627021423.18404-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 27 Jun 2018 02:15:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/6] docker: Make _get_so_libs() work on 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: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The "ldd" output is a byte sequence, not a string. Use bytes literals while handling the output, and use os.fsdecode() on the resulting file paths before returning. Signed-off-by: Eduardo Habkost --- tests/docker/docker.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/docker/docker.py b/tests/docker/docker.py index bc34bd872b..f58af8e894 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -41,6 +41,15 @@ FILTERED_ENV_NAMES =3D ['ftp_proxy', 'http_proxy', 'http= s_proxy'] =20 DEVNULL =3D open(os.devnull, 'wb') =20 +def _fsdecode(name): + # type: (bytes) -> str + """Decode filename to str, try to use os.fsdecode() if available""" + if hasattr(os, 'fsdecode'): + # Python 3 + return os.fsdecode(name) # type: ignore + else: + # Python 2.7 + return name # type: ignore =20 def _text_checksum(text): # type: (bytes) -> str @@ -90,15 +99,15 @@ def _get_so_libs(executable): ensure theright data is copied.""" =20 libs =3D [] - ldd_re =3D re.compile(r"(/.*/)(\S*)") + ldd_re =3D re.compile(b"(/.*/)(\S*)") try: ldd_output =3D subprocess.check_output(["ldd", executable]) - for line in ldd_output.split("\n"): + for line in ldd_output.split(b"\n"): search =3D ldd_re.search(line) if search and len(search.groups()) =3D=3D 2: so_path =3D search.groups()[0] so_lib =3D search.groups()[1] - libs.append("%s/%s" % (so_path, so_lib)) + libs.append(_fsdecode(b"%s/%s" % (so_path, so_lib))) except subprocess.CalledProcessError: print("%s had no associated libraries (static build?)" % (executab= le)) =20 --=20 2.18.0.rc1.1.g3f1ff2140