From: Gregory P. Smith Date: Sat, 19 Jan 2008 20:49:02 +0000 (+0000) Subject: fix comment typos, use not arg instead of arg == "", add test coverage X-Git-Tag: v2.6a1~524 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e047e6dd092a7d8f512914de78a8193ba6c518c4;p=python fix comment typos, use not arg instead of arg == "", add test coverage for inside of the final if needquotes: within subprocess.list2cmdline(). --- diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 29c25bcd3a..a94490c26b 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -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) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 33aa013665..a7e309ef56 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -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']),