[ python-Bugs-1634343 ] subprocess swallows empty arguments under win32

SourceForge.net noreply at sourceforge.net
Sat Jan 13 23:37:46 CET 2007


Bugs item #1634343, was opened at 2007-01-12 21:40
Message generated for change (Comment added) made by astrand
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1634343&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Windows
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Patrick Mézard (pmezard)
>Assigned to: Peter Åstrand (astrand)
Summary: subprocess swallows empty arguments under win32

Initial Comment:
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


----------------------------------------------------------------------

>Comment By: Peter Åstrand (astrand)
Date: 2007-01-13 23:37

Message:
Logged In: YES 
user_id=344921
Originator: NO

Fixed in revision 53412 (trunk) and 53413 (25-maint). 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1634343&group_id=5470


More information about the Python-bugs-list mailing list