From: W. Trevor King Date: Wed, 6 Feb 2013 21:38:40 +0000 (-0500) Subject: ui.cli: Fix ._set_ps1 when .question is None X-Git-Tag: v0.1~15 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0ee85fb969c921495a6756353def836f25262ccc;p=quizzer.git ui.cli: Fix ._set_ps1 when .question is None Otherwise QuestionCommandLine will crash if its launched with an empty stack (not that this should happen, but we should still avoid the crash). --- diff --git a/quizzer/ui/cli.py b/quizzer/ui/cli.py index 1cf01b1..f133362 100644 --- a/quizzer/ui/cli.py +++ b/quizzer/ui/cli.py @@ -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)"