]> granicus.if.org Git - python/commitdiff
Issue #8513: On UNIX, subprocess supports bytes command string.
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 3 Mar 2011 12:54:05 +0000 (12:54 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 3 Mar 2011 12:54:05 +0000 (12:54 +0000)
Lib/subprocess.py
Lib/test/test_subprocess.py
Misc/NEWS

index c02fb525ec57af9f3cf93e86d7158a3778ba2cf6..359dc96701a99e49f4d31c1dc681ff99f44811da 100644 (file)
@@ -1125,7 +1125,7 @@ class Popen(object):
                            restore_signals, start_new_session):
             """Execute program (POSIX version)"""
 
-            if isinstance(args, str):
+            if isinstance(args, (str, bytes)):
                 args = [args]
             else:
                 args = list(args)
index 9e267ebf59e14518325a9e1ea25871b02d4bdcf7..d91a4a6987cb47b367724d20a004f44ca05cec05 100644 (file)
@@ -1059,6 +1059,11 @@ class POSIXProcessTestCase(BaseTestCase):
         exitcode = subprocess.call([abs_program, "-c", "pass"])
         self.assertEqual(exitcode, 0)
 
+        # absolute bytes path as a string
+        cmd = b"'" + abs_program + b"' -c pass"
+        exitcode = subprocess.call(cmd, shell=True)
+        self.assertEqual(exitcode, 0)
+
         # bytes program, unicode PATH
         env = os.environ.copy()
         env["PATH"] = path
index da1b75d0274a5edea48a95b8e5c6d13b9becc2ff..128efa23e3c34d6d4a1afaf7e5f7f3b12c9564f9 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -52,6 +52,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #8513: On UNIX, subprocess supports bytes command string.
+
 - Issue #10866: Add socket.sethostname().  Initial patch by Ross Lagerwall.
 
 - Issue #11140: Lock.release() now raises a RuntimeError when attempting