summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-01-19 22:49:37 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-01-19 22:49:37 (GMT)
commit70eb2f91b45e126ca8219d965b1d14968b0405cc (patch)
tree72ef3cbac75909f93ab5f195488e1b9b7dd6483a
parent92ffc634e48268d357f6bde2ed1b7ac26bfb2631 (diff)
downloadcpython-70eb2f91b45e126ca8219d965b1d14968b0405cc.zip
cpython-70eb2f91b45e126ca8219d965b1d14968b0405cc.tar.gz
cpython-70eb2f91b45e126ca8219d965b1d14968b0405cc.tar.bz2
Fix issue 1300: Quote command line arguments that contain a '|' character in
subprocess.list2cmdline (windows).
-rw-r--r--Lib/subprocess.py6
-rw-r--r--Lib/test/test_subprocess.py2
2 files changed, 5 insertions, 3 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index bae4259..975a924 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -471,8 +471,8 @@ def list2cmdline(seq):
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 @@ def list2cmdline(seq):
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('"')
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index a7e309e..9886f3d 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -434,6 +434,8 @@ class ProcessTestCase(unittest.TestCase):
'"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):