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'
"""
# 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