[Python-checkins] r60115 - in python/trunk/Lib: subprocess.py test/test_subprocess.py

gregory.p.smith python-checkins at python.org
Sat Jan 19 23:49:37 CET 2008


Author: gregory.p.smith
Date: Sat Jan 19 23:49:37 2008
New Revision: 60115
Modified:
 python/trunk/Lib/subprocess.py
 python/trunk/Lib/test/test_subprocess.py
Log:
Fix issue 1300: Quote command line arguments that contain a '|' character in
subprocess.list2cmdline (windows).
Modified: python/trunk/Lib/subprocess.py
==============================================================================
--- python/trunk/Lib/subprocess.py	(original)
+++ python/trunk/Lib/subprocess.py	Sat Jan 19 23:49:37 2008
@@ -471,8 +471,8 @@
 
 2) A string surrounded by double quotation marks is
 interpreted as a single argument, regardless of white space
- contained within. A quoted string can be embedded in an
- argument.
+ or pipe characters contained within. A quoted string can be
+ embedded in an argument.
 
 3) A double quotation mark preceded by a backslash is
 interpreted as a literal double quotation mark.
@@ -498,7 +498,7 @@
 if result:
 result.append(' ')
 
- needquote = (" " in arg) or ("\t" in arg) or not arg
+ needquote = (" " in arg) or ("\t" in arg) or ("|" in arg) or not arg
 if needquote:
 result.append('"')
 
Modified: python/trunk/Lib/test/test_subprocess.py
==============================================================================
--- python/trunk/Lib/test/test_subprocess.py	(original)
+++ python/trunk/Lib/test/test_subprocess.py	Sat Jan 19 23:49:37 2008
@@ -434,6 +434,8 @@
 '"a\\\\b\\ c" d e')
 self.assertEqual(subprocess.list2cmdline(['ab', '']),
 'ab ""')
+ self.assertEqual(subprocess.list2cmdline(['echo', 'foo|bar']),
+ 'echo "foo|bar"')
 
 
 def test_poll(self):


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /