On 8 September 2011 23:07, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net">eric@anholt.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
---<br>
framework/exectest.py | 5 +++++<br>
1 files changed, 5 insertions(+), 0 deletions(-)<br>
<br>
diff --git a/framework/exectest.py b/framework/exectest.py<br>
index dc9dc9e..59cb090 100644<br>
--- a/framework/exectest.py<br>
+++ b/framework/exectest.py<br>
@@ -23,6 +23,8 @@<br>
<br>
import os<br>
import subprocess<br>
+import string<br>
+import types<br>
<br>
from core import Test, testBinDir, TestResult<br>
<br>
@@ -36,6 +38,9 @@ class ExecTest(Test):<br>
self.command = command<br>
self.env = {}<br>
<br>
+ if type(self.command) is types.StringType:<br>
+ self.command = string.split(self.command)<br>
+<br></blockquote><div><br>The standard Python idiom for testing whether a thing is a string is "isinstance(..., basestring)" rather than "type(...) is types.StringType". This would ensure that ExecTest() would work properly even if passed a unicode string. (Unicode strings crop up in Python more often than you might realize, since any string manipulation that involves both unicode and non-unicode strings produces a unicode string as a result, even if the result doesn't contain any non-ascii characters).<br>
<br>Also, string.split(s) is deprecated in favor of s.split(), and will be removed in Python 3.0 (see <a href="http://docs.python.org/library/string.html#deprecated-string-functions">http://docs.python.org/library/string.html#deprecated-string-functions</a>).<br>
<br><br><br>Just to go on record with what I said in person on Thursday, I think it would be preferable to use shlex.split() rather than string.split(), so that you get standard shell-style string splitting behavior, for example:<br>
<br> shlex.split('foo "bar baz"') == ['foo', 'bar baz']<br><br>This wouldn't break any of the uses of ExecTest() that you are enabling, and it would make life easier in the future for anyone who needed to pass a multi-word argument to a test program using ExecTest().<br>
</div></div>