git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGIT PATCH 3/4] Assert that the argument to Run is a sequence of strings

From
Karl Hasselström <kha@treskal.com>
Date
Aug 26, 2007, 20:33 UTC
Message-ID
<20070826203339.16265.43048.stgit@yoghurt>
In-Reply-To
<20070826202724.16265.85821.stgit@yoghurt>
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 |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/stgit/run.py b/stgit/run.py
index d925cce..1bc4759 100644
--- a/stgit/run.py
+++ b/stgit/run.py
@@ -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
Previous: Karl HasselströmNext: Karl Hasselström
Message 4 of 14 in “Clean up subprocess calling”
  1. 0/4 Clean up subprocess callingKarl Hasselström, Aug 26, 2007
  2. 1/4 Refactor output handling to break circular dependencyKarl Hasselström, Aug 26, 2007
  3. 2/4 Refactor subprocess creationKarl Hasselström, Aug 26, 2007
  4. 3/4 Assert that the argument to Run is a sequence of stringsKarl Hasselström, Aug 26, 2007
  5. 4/4 Add optional logging of subprocess executionKarl Hasselström, Aug 26, 2007
  6. Catalin MarinasAug 29, 2007
  7. Karl HasselströmAug 29, 2007
  8. Karl HasselströmAug 29, 2007
  9. Catalin MarinasSep 3, 2007
  10. Catalin MarinasSep 3, 2007
  11. Karl HasselströmSep 3, 2007
  12. 0/2 Break Python 2.3 compatibilityKarl Hasselström, Sep 3, 2007
  13. 1/2 Use subprocess.Popen to call git executablesKarl Hasselström, Sep 3, 2007
  14. 2/2 Use the builtin set() instead of sets.Set()Karl Hasselström, Sep 3, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.