From 74032037775ece0b2086e4231a93c9825f246553 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 25 Jun 2019 15:16:18 +0200 Subject: Make choice.set_value() no-change check work for "n"/"m"/"y" strings Same deal as in commit f2ac5e3 ("Make set_value() no-change check work for "n"/"m"/"y" strings"). Overlooked the similar logic for choices. --- kconfiglib.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/kconfiglib.py b/kconfiglib.py index 3e64e38..01561bc 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -5094,29 +5094,28 @@ class Choice(object): Choice.assignable attribute to see what values are currently in range and would actually be reflected in the mode of the choice. """ + if value in STR_TO_TRI: + value = STR_TO_TRI[value] + if value == self.user_value: # We know the value must be valid if it was successfully set # previously self._was_set = True return True - if not ((self.orig_type is BOOL and value in (2, 0, "y", "n") ) or - (self.orig_type is TRISTATE and value in (2, 1, 0, "y", "m", "n"))): + if not (self.orig_type is BOOL and value in (2, 0) or + self.orig_type is TRISTATE and value in TRI_TO_STR): # Display tristate values as n, m, y in the warning self.kconfig._warn( "the value {} is invalid for {}, which has type {} -- " "assignment ignored" - .format(TRI_TO_STR[value] if value in (0, 1, 2) else + .format(TRI_TO_STR[value] if value in TRI_TO_STR else "'{}'".format(value), - _name_and_loc(self), - TYPE_TO_STR[self.orig_type])) + _name_and_loc(self), TYPE_TO_STR[self.orig_type])) return False - if value in ("y", "m", "n"): - value = STR_TO_TRI[value] - self.user_value = value self._was_set = True self._rec_invalidate() -- cgit v1.2.3