From 0ee85fb969c921495a6756353def836f25262ccc Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 6 Feb 2013 16:38:40 -0500 Subject: [PATCH] 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). --- quizzer/ui/cli.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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)" -- 2.26.2