chiark / gitweb /
Assert that the argument to Run is a sequence of strings
authorKarl Hasselström <kha@treskal.com>
Fri, 24 Aug 2007 11:26:01 +0000 (13:26 +0200)
committerKarl Hasselström <kha@treskal.com>
Sun, 26 Aug 2007 20:04:10 +0000 (22:04 +0200)
This runtime assertion makes bugs easier to find.

In most other languages, we'd have been able to check this at compile
time. But this is Python. Yay!

Signed-off-by: Karl Hasselström <kha@treskal.com>
stgit/run.py

index d925ccea68c6200f9aae90330ec5366a2d06c862..1bc47595b1f9dabb3bffbbf498b27cc839068e9a 100644 (file)
@@ -31,6 +31,9 @@ class Run:
     exc = RunException
     def __init__(self, *cmd):
         self.__cmd = list(cmd)
+        for c in cmd:
+            if type(c) != str:
+                raise Exception, 'Bad command: %r' % cmd
         self.__good_retvals = [0]
         self.__env = None
         self.__indata = None