ui.cli: Fix ._set_ps1 when .question is None
authorW. Trevor King <wking@tremily.us>
Wed, 6 Feb 2013 21:38:40 +0000 (16:38 -0500)
committerW. Trevor King <wking@tremily.us>
Wed, 6 Feb 2013 21:39:04 +0000 (16:39 -0500)
Otherwise QuestionCommandLine will crash if its launched with an empty
stack (not that this should happen, but we should still avoid the
crash).

quizzer/ui/cli.py

index 1cf01b1a3fb418eb29e7e9b129c7c0db50581515..f133362f2a773069a094d5816fe3f2f46ae28845 100644 (file)
@@ -46,8 +46,11 @@ class QuestionCommandLine (_cmd.Cmd):
 
     def _set_ps1(self):
         "Pose a question and prompt"
-        self.prompt = '\n{}\n{}'.format(
-            self.question.format_prompt(), self._prompt)
+        if self.question:
+            self.prompt = '\n{}\n{}'.format(
+                self.question.format_prompt(), self._prompt)
+        else:
+            self.prompt = self._prompt
 
     def _set_ps2(self):
         "Just prompt (without the question, e.g. for multi-line answers)"