Index: Lib/subprocess.py =================================================================== --- Lib/subprocess.py (revision 61420) +++ Lib/subprocess.py (working copy) @@ -784,7 +784,7 @@ startupinfo.dwFlags |= STARTF_USESHOWWINDOW startupinfo.wShowWindow = SW_HIDE comspec = os.environ.get("COMSPEC", "cmd.exe") - args = comspec + " /c " + args + args = comspec + " /c " + '"%s"' % args if (GetVersion() >= 0x80000000L or os.path.basename(comspec).lower() == "command.com"): # Win9x, or using command.com on NT. We need to Index: Lib/test/test_subprocess.py =================================================================== --- Lib/test/test_subprocess.py (revision 61420) +++ Lib/test/test_subprocess.py (working copy) @@ -654,7 +654,46 @@ rc = subprocess.call(sys.executable + ' -c "import sys; sys.exit(47)"') self.assertEqual(rc, 47) + + def test_call_string_with_spaces(self): + # call() function with spaces in the command and parameter + temp = os.environ['TEMP'] + exe = os.path.join(temp, "py thon.exe") + f = open(exe, "wb") + try: + f.write(open (sys.executable, "rb").read ()) + finally: + f.close() + py = os.path.join(temp, "py thon.py") + f = open(py, "w") + try: + f.write("import sys\nprint sys.executable\n") + finally: + f.close() + p = subprocess.Popen(exe + " " + py) + p.wait() + os.remove(exe) + os.remove(py) + def test_call_args_with_spaces(self): + # call() function with spaces in the command and parameter + temp = os.environ['TEMP'] + exe = os.path.join(temp, "py thon.exe") + f = open(exe, "wb") + try: + f.write(open (sys.executable, "rb").read ()) + finally: + f.close() + py = os.path.join(temp, "py thon.py") + f = open(py, "w") + try: + f.write("import sys\nprint sys.executable\n") + finally: + f.close() + p = subprocess.Popen([exe, py]) + p.wait() + os.remove(exe) + os.remove(py) def test_main(): test_support.run_unittest(ProcessTestCase)