From 15b98eb570a734c9505cb3b82674e7dc36c90b56 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 2 May 2012 12:55:31 -0700 Subject: dispatch-conf: use shlex to parse diff command --- pym/portage/dispatch_conf.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'pym/portage/dispatch_conf.py') diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py index c81153ae1..4c68dfc7b 100644 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@ -13,7 +13,7 @@ import os, shutil, subprocess, sys import portage from portage.env.loaders import KeyValuePairFileLoader from portage.localization import _ -from portage.util import varexpand +from portage.util import shlex_split, varexpand RCS_BRANCH = '1.1.1' RCS_LOCK = 'rcs -ko -M -l' @@ -30,8 +30,12 @@ def diffstatusoutput(cmd, file1, file2): """ # Use Popen to emulate getstatusoutput(), since getstatusoutput() may # raise a UnicodeDecodeError which makes the output inaccessible. - proc = subprocess.Popen(cmd % (file1, file2), - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + args = shlex_split(cmd % (file1, file2)) + if sys.hexversion < 0x3000000 or sys.hexversion >= 0x3020000: + # Python 3.1 does not support bytes in Popen args. + args = [portage._unicode_encode(x, errors='strict') for x in args] + proc = subprocess.Popen(args, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = portage._unicode_decode(proc.communicate()[0]) if output and output[-1] == "\n": # getstatusoutput strips one newline -- cgit v1.2.3-1-g7c22