[Python-checkins] r88720 - in python/branches/py3k: Lib/subprocess.py Lib/test/test_subprocess.py Misc/NEWS

victor.stinner python-checkins at python.org
Thu Mar 3 13:54:05 CET 2011


Author: victor.stinner
Date: Thu Mar  3 13:54:05 2011
New Revision: 88720

Log:
Issue #8513: On UNIX, subprocess supports bytes command string.

Modified:
   python/branches/py3k/Lib/subprocess.py
   python/branches/py3k/Lib/test/test_subprocess.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/subprocess.py
==============================================================================
--- python/branches/py3k/Lib/subprocess.py	(original)
+++ python/branches/py3k/Lib/subprocess.py	Thu Mar  3 13:54:05 2011
@@ -1125,7 +1125,7 @@
                            restore_signals, start_new_session):
             """Execute program (POSIX version)"""
 
-            if isinstance(args, str):
+            if isinstance(args, (str, bytes)):
                 args = [args]
             else:
                 args = list(args)

Modified: python/branches/py3k/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/py3k/Lib/test/test_subprocess.py	(original)
+++ python/branches/py3k/Lib/test/test_subprocess.py	Thu Mar  3 13:54:05 2011
@@ -1059,6 +1059,11 @@
         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

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Thu Mar  3 13:54:05 2011
@@ -52,6 +52,8 @@
 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


More information about the Python-checkins mailing list