[Python-checkins] r83831 - in python/branches/release31-maint/Lib: subprocess.py test/test_subprocess.py

Eric Smith eric at trueblade.com
Mon Aug 9 00:31:20 CEST 2010


On 8/8/10 12:18 PM, tim.golden wrote:
> Modified: python/branches/release31-maint/Lib/subprocess.py
> ==============================================================================
> --- python/branches/release31-maint/Lib/subprocess.py	(original)
> +++ python/branches/release31-maint/Lib/subprocess.py	Sun Aug  8 18:18:18 2010
> @@ -829,7 +829,7 @@
>                   startupinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW
>                   startupinfo.wShowWindow = _subprocess.SW_HIDE
>                   comspec = os.environ.get("COMSPEC", "cmd.exe")
> -                args = comspec + " /c " + args
> +                args = comspec + " /c " + '"%s"' % args
>                   if (_subprocess.GetVersion()>= 0x80000000 or
>                           os.path.basename(comspec).lower() == "command.com"):
>                       # Win9x, or using command.com on NT. We need to

If args is a tuple, this fails with a TypeError. I realize args 
shouldn't be a tuple, but that's not a great failure if it is. I think 
this would be better written as:

      args = '{} /c "{}"'.format(compspec, args)


-- 
Eric.


More information about the Python-checkins mailing list