summaryrefslogtreecommitdiffstats
path: root/pym/portage/dispatch_conf.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-03-31 10:22:13 -0700
committerZac Medico <zmedico@gentoo.org>2012-03-31 10:22:13 -0700
commit3f7a3b294dd38c6009d41ce7f40075e2e2645c6e (patch)
tree0cda5d01145e33882cd0a801e66b85a4e11957bc /pym/portage/dispatch_conf.py
parent5dbea626d2305625b1562eebfde4fe7b4ee601d9 (diff)
downloadportage-3f7a3b294dd38c6009d41ce7f40075e2e2645c6e.tar.gz
portage-3f7a3b294dd38c6009d41ce7f40075e2e2645c6e.tar.bz2
portage-3f7a3b294dd38c6009d41ce7f40075e2e2645c6e.zip
dispatch_conf: emulate getstatusoutput with Popen
This will fix bug #410315.
Diffstat (limited to 'pym/portage/dispatch_conf.py')
-rw-r--r--pym/portage/dispatch_conf.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py
index 3d53f6405..cc98fad16 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-conf
-# Copyright 2003-2011 Gentoo Foundation
+# Copyright 2003-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
@@ -8,7 +8,7 @@
from __future__ import print_function
-import os, sys, shutil
+import os, shutil, subprocess, sys
import portage
from portage.env.loaders import KeyValuePairFileLoader
@@ -26,17 +26,17 @@ DIFF3_MERGE = "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 = portage.subprocess_getstatusoutput(cmd % (file1, file2))
- return (status, output)
- except UnicodeDecodeError:
- return (1, 1)
+ # Use Popen to emulate getstatusoutput(), since getstatusoutput() may
+ # raise a UnicodeDecodeError which makes the output inaccessible.
+ proc = subprocess.Popen(portage._unicode_encode(cmd % (file1, file2)),
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
+ output = portage._unicode_decode(proc.communicate()[0])
+ if output and output[-1] == "\n":
+ # getstatusoutput strips one newline
+ output = output[:-1]
+ return (proc.wait(), output)
def read_config(mandatory_opts):
eprefix = portage.const.EPREFIX