This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: subprocess swallows empty arguments under win32
Type: Stage:
Components: Windows Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: astrand Nosy List: astrand, pmezard
Priority: normal Keywords:

Created on 2007-01-12 20:40 by pmezard, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg31007 - (view) Author: Patrick Mézard (pmezard) Date: 2007-01-12 20:40
Hello,
empty arguments are not quoted by subprocess.list2cmdline. Therefore nothing is concatenated with other arguments. To reproduce it:

test-empty.py
"""
import sys
print sys.argv
"""

then:
"""
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> p = subprocess.Popen(['python', 'test-empty.py', ''], stdout=subprocess.PIPE)
>>> p.communicate()
("['test-empty.py']\r\n", None)
"""

To solve it:
"""
--- a\subprocess.py     2007-01-12 21:38:57.734375000 +0100
+++ b\subprocess.py     2007-01-12 21:34:08.406250000 +0100
@@ -499,7 +499,7 @@
         if result:
             result.append(' ')

-        needquote = (" " in arg) or ("\t" in arg)
+        needquote = (" " in arg) or ("\t" in arg) or not arg
         if needquote:
             result.append('"')
"""

Regard,
Patrick Mézard
msg31008 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2007-01-13 22:37
Fixed in revision 53412 (trunk) and 53413 (25-maint). 
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44455
2007-01-12 20:40:46pmezardcreate