repoman: fix os.system() unicode, bug #310789
authorZac Medico <zmedico@gentoo.org>
Mon, 10 Sep 2012 20:45:23 +0000 (13:45 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 10 Sep 2012 20:45:23 +0000 (13:45 -0700)
bin/repoman

index 54a7c5b8e49834eab0e9082de44315b37c08e8ee..53d138c8d12c881e5e5873df12b2763f523fc860 100755 (executable)
@@ -2786,7 +2786,13 @@ else:
                if options.pretend:
                        print("("+gpgcmd+")")
                else:
-                       rValue = os.system(gpgcmd)
+                       # Encode unicode manually for bug #310789.
+                       gpgcmd = portage.util.shlex_split(gpgcmd)
+                       if sys.hexversion < 0x3000000 or sys.hexversion >= 0x3020000:
+                               # Python 3.1 does not support bytes in Popen args.
+                               gpgcmd = [_unicode_encode(arg,
+                                       encoding=_encodings['fs'], errors='strict') for arg in gpgcmd]
+                       rValue = subprocess.call(gpgcmd)
                        if rValue == os.EX_OK:
                                os.rename(filename+".asc", filename)
                        else: