From 185f694f599927e8a9bb6f2495744116429fc43b Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Tue, 23 Dec 2014 03:39:42 +0100 Subject: [PATCH] Assure that questions are actually strings --- question.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/question.py b/question.py index f289ce5..7e4dd2e 100644 --- a/question.py +++ b/question.py @@ -69,6 +69,12 @@ class Questions(object): if any([x not in q.keys() for x in ["Question", "Answer", "Type"]]): raise QuestionException("Question %d from section %d (%s) is missing one of the keywords Question, Answer or Type" % (j, i, sec["Section"])) + # check wether the question is a string (else we'll get display errors) + if type(q["Question"]) != str: + raise QuestionException("Question %d from section %d (%s) needs to have a string as question (put the Question in \"\")" % (j, i, sec["Section"])) + print(type(q["Question"])) + + # check for keys we do not know for key in q.keys(): if key not in self.QUESTION_KEYS: