From 214b37dfdb575d062453180541a7e72ea79bece6 Mon Sep 17 00:00:00 2001 From: John Donaldson Date: Tue, 9 Jul 2019 18:59:57 +0100 Subject: [PATCH] Force answers to be provided as strings --- devel/moth.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/devel/moth.py b/devel/moth.py index c74d8ee..890f2f2 100644 --- a/devel/moth.py +++ b/devel/moth.py @@ -143,10 +143,13 @@ class Puzzle: elif key == 'summary': self.summary = val elif key == 'answer': + if not isinstance(val, str): + raise ValueError("Answers must be strings, got %s, instead" % (type(val),)) self.answers.append(val) elif key == "answers": for answer in val: - answer = str(answer) + if not isinstance(answer, str): + raise ValueError("Answers must be strings, got %s, instead" % (type(answer),)) self.answers.append(answer) elif key == 'pattern': self.pattern = val