Fix CommandOutputSet to decode binary command output in py3k.
authorZac Medico <zmedico@gentoo.org>
Fri, 27 Feb 2009 03:08:03 +0000 (03:08 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 27 Feb 2009 03:08:03 +0000 (03:08 -0000)
svn path=/main/trunk/; revision=12721

pym/portage/sets/shell.py

index ba1b2422fffeaccf9cde8b7f8aed860931b6a615..75912c0becd57aa49c8e8c079732f237796038ca 100644 (file)
@@ -4,6 +4,7 @@
 
 import subprocess
 import os
+import sys
 
 from portage.sets.base import PackageSet
 from portage.sets import SetConfigError
@@ -35,8 +36,11 @@ class CommandOutputSet(PackageSet):
                pipe = subprocess.Popen(self._command, stdout=subprocess.PIPE, shell=True)
                if pipe.wait() == os.EX_OK:
                        text = pipe.stdout.read()
-                       self._setAtoms(text.split("\n"))
-               
+                       if sys.hexversion >= 0x3000000:
+                               encoding = sys.getdefaultencoding()
+                               text = text.decode(encoding, 'replace')
+                       self._setAtoms(text.splitlines())
+
        def singleBuilder(self, options, settings, trees):
                if not "command" in options:
                        raise SetConfigError("no command specified")