]> granicus.if.org Git - python/commitdiff
fix comment typos, use not arg instead of arg == "", add test coverage
authorGregory P. Smith <greg@mad-scientist.com>
Sat, 19 Jan 2008 20:49:02 +0000 (20:49 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Sat, 19 Jan 2008 20:49:02 +0000 (20:49 +0000)
for inside of the final if needquotes: within subprocess.list2cmdline().

Lib/subprocess.py
Lib/test/test_subprocess.py

index 29c25bcd3aa70d07b50d10653dc190ba58569608..a94490c26bb08ecb5f868d37e5b06fad37111b8e 100644 (file)
@@ -497,7 +497,7 @@ def list2cmdline(seq):
         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 @@ def list2cmdline(seq):
                 # 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 @@ def list2cmdline(seq):
                     bs_buf = []
                 result.append(c)
 
-        # Add remaining backspaces, if any.
+        # Add remaining backslashes, if any.
         if bs_buf:
             result.extend(bs_buf)
 
index 33aa013665ad76c8f94234a1a5f0ad9531bb0c72..a7e309ef5642805c733ee3c6c1f14d1b0facf17c 100644 (file)
@@ -422,6 +422,8 @@ class ProcessTestCase(unittest.TestCase):
                          '"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']),