From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SE21j-0003m9-Fa for garchives@archives.gentoo.org; Sat, 31 Mar 2012 17:23:47 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9D11321C04E; Sat, 31 Mar 2012 17:22:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 7035021C04E for ; Sat, 31 Mar 2012 17:22:30 +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 A2C711B4004 for ; Sat, 31 Mar 2012 17:22:29 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 62D5CE5402 for ; Sat, 31 Mar 2012 17:22:28 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1333214533.3f7a3b294dd38c6009d41ce7f40075e2e2645c6e.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dispatch_conf.py X-VCS-Directories: pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 3f7a3b294dd38c6009d41ce7f40075e2e2645c6e X-VCS-Branch: master Date: Sat, 31 Mar 2012 17:22:28 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: e4e0c6c9-d5e1-402b-9b53-3182e364fa8f X-Archives-Hash: 0bb0d53cc022c1b37de609d6e9860226 commit: 3f7a3b294dd38c6009d41ce7f40075e2e2645c6e Author: Zac Medico gentoo org> AuthorDate: Sat Mar 31 17:22:13 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Mar 31 17:22:13 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D3f7a3b29 dispatch_conf: emulate getstatusoutput with Popen This will fix bug #410315. --- pym/portage/dispatch_conf.py | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py index 3d53f64..cc98fad 100644 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@ -1,5 +1,5 @@ # archive_conf.py -- functionality common to archive-conf and dispatch-c= onf -# Copyright 2003-2011 Gentoo Foundation +# Copyright 2003-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 =20 @@ -8,7 +8,7 @@ =20 from __future__ import print_function =20 -import os, sys, shutil +import os, shutil, subprocess, sys =20 import portage from portage.env.loaders import KeyValuePairFileLoader @@ -26,17 +26,17 @@ DIFF3_MERGE =3D "diff3 -mE '%s' '%s' '%s' > '%s'" def diffstatusoutput(cmd, file1, file2): """ Execute the string cmd in a shell with getstatusoutput() and return = a - 2-tuple (status, output). If getstatusoutput() raises - UnicodeDecodeError (known to happen with python3.1), return a - 2-tuple (1, 1). This provides a simple way to check for non-zero - output length of diff commands, while providing simple handling of - UnicodeDecodeError when necessary. + 2-tuple (status, output). """ - try: - status, output =3D portage.subprocess_getstatusoutput(cmd % (fil= e1, file2)) - return (status, output) - except UnicodeDecodeError: - return (1, 1) + # Use Popen to emulate getstatusoutput(), since getstatusoutput() ma= y + # raise a UnicodeDecodeError which makes the output inaccessible. + proc =3D subprocess.Popen(portage._unicode_encode(cmd % (file1, file= 2)), + stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.STDOUT, shell=3DTr= ue) + output =3D portage._unicode_decode(proc.communicate()[0]) + if output and output[-1] =3D=3D "\n": + # getstatusoutput strips one newline + output =3D output[:-1] + return (proc.wait(), output) =20 def read_config(mandatory_opts): eprefix =3D portage.const.EPREFIX