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

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


Author: gregory.p.smith
Date: Sat Jan 19 21:49:02 2008
New Revision: 60102
Modified:
 python/trunk/Lib/subprocess.py
 python/trunk/Lib/test/test_subprocess.py
Log:
fix comment typos, use not arg instead of arg == "", add test coverage
for inside of the final if needquotes: within subprocess.list2cmdline().
Modified: python/trunk/Lib/subprocess.py
==============================================================================
--- python/trunk/Lib/subprocess.py	(original)
+++ python/trunk/Lib/subprocess.py	Sat Jan 19 21:49:02 2008
@@ -497,7 +497,7 @@
 if result:
 result.append(' ')
 
- needquote = (" " in arg) or ("\t" in arg) or arg == ""
+ needquote = (" " in arg) or ("\t" in arg) or not arg
 if needquote:
 result.append('"')
 
@@ -506,7 +506,7 @@
 # Don't know if we need to double yet.
 bs_buf.append(c)
 elif c == '"':
- # Double backspaces.
+ # Double backslashes.
 result.append('\\' * len(bs_buf)*2)
 bs_buf = []
 result.append('\\"')
@@ -517,7 +517,7 @@
 bs_buf = []
 result.append(c)
 
- # Add remaining backspaces, if any.
+ # Add remaining backslashes, if any.
 if bs_buf:
 result.extend(bs_buf)
 
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 21:49:02 2008
@@ -422,6 +422,8 @@
 '"a b c" d e')
 self.assertEqual(subprocess.list2cmdline(['ab"c', '\\', 'd']),
 'ab\\"c \\ d')
+ self.assertEqual(subprocess.list2cmdline(['ab"c', ' \\', 'd']),
+ 'ab\\"c " \\\\" d')
 self.assertEqual(subprocess.list2cmdline(['a\\\\\\b', 'de fg', 'h']),
 'a\\\\\\b "de fg" h')
 self.assertEqual(subprocess.list2cmdline(['a\\"b', 'c', 'd']),


More information about the Python-checkins mailing list

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