From 4a406b6930bdbde1240c5cddb7accee3f4a27c6d Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Wed, 23 Aug 2017 11:08:39 -0300 Subject: [PATCH] Fix invalid choice not int --- choice/basicterm.py | 5 ++--- choice/util.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/choice/basicterm.py b/choice/basicterm.py index 902a40e..1314df4 100644 --- a/choice/basicterm.py +++ b/choice/basicterm.py @@ -28,7 +28,7 @@ def pick_choice(self): end = start + self.PAGE_SIZE for i, c in enumerate(self.choices[start:end]): print(" {}: {}".format(i, c[1])) - if self.global_actions is not None: + if self.global_actions: print() for ga in self.global_actions: if ga[0] == ga[1]: @@ -84,7 +84,7 @@ def ask(self): print("{} is not a valid choice".format(resp)) assert choice is not None - if self.actions is None or len(self.actions) == 1: + if len(self.actions) <= 1: return choice[0] action = None @@ -149,4 +149,3 @@ def ask(self): else: print("Please answer 'y'es or 'n'o") return self.ask() - diff --git a/choice/util.py b/choice/util.py index f612a8f..6a4e2b7 100644 --- a/choice/util.py +++ b/choice/util.py @@ -1,7 +1,7 @@ # outlist contains elements (id, display) def idNameList(inlist): if inlist is None: - return None + return [] outlist = [] for item in inlist: