From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 925E11381F3 for ; Fri, 21 Jun 2013 23:07:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1D588E0BA1; Fri, 21 Jun 2013 23:07:54 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A9901E0BA1 for ; Fri, 21 Jun 2013 23:07:53 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BFBA333E49D for ; Fri, 21 Jun 2013 23:07:52 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 65808E468F for ; Fri, 21 Jun 2013 23:07:51 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1371856051.d31b8be0806815b1c01f36ec4b83126b1483c8b6.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/install.py X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: d31b8be0806815b1c01f36ec4b83126b1483c8b6 X-VCS-Branch: master Date: Fri, 21 Jun 2013 23:07:51 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: c5219020-ceaf-47e8-94a5-058b439dd87b X-Archives-Hash: cb7b209631f7ccd662939fe2aa7530d0 commit: d31b8be0806815b1c01f36ec4b83126b1483c8b6 Author: Zac Medico gentoo org> AuthorDate: Fri Jun 21 23:07:31 2013 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Jun 21 23:07:31 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d31b8be0 install.py: use surrogateescape for Python >=3.2 We can't trust that the filesystem encoding (locale dependent) correctly matches the arguments, so use surrogateescape to pass through the original argv bytes for Python 3. Since Python <3.2 does not support bytes in Popen args, trust the locale in that case. --- bin/install.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bin/install.py b/bin/install.py index 2ca62f2..f7118a6 100755 --- a/bin/install.py +++ b/bin/install.py @@ -223,6 +223,20 @@ def main(args): path_installs = Which('install', all=True) cmdline = path_installs[0:1] cmdline += args + + if sys.hexversion >= 0x3020000: + # We can't trust that the filesystem encoding (locale dependent) + # correctly matches the arguments, so use surrogateescape to + # pass through the original argv bytes for Python 3. + # Since Python <3.2 does not support bytes in Popen args, trust + # the locale in that case. + fs_encoding = sys.getfilesystemencoding() + cmdline = [x.encode(fs_encoding, 'surrogateescape') for x in cmdline] + files = [x.encode(fs_encoding, 'surrogateescape') for x in files] + if opts.target_directory is not None: + opts.target_directory = \ + opts.target_directory.encode(fs_encoding, 'surrogateescape') + returncode = subprocess.call(cmdline) if returncode == os.EX_OK: returncode = copy_xattrs(opts, files)