diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-06-25 15:16:18 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-06-25 15:47:24 +0200 |
| commit | 74032037775ece0b2086e4231a93c9825f246553 (patch) | |
| tree | 4ad1257f1f9f3b0aac87f507d4e7d306a2550717 /kconfiglib.py | |
| parent | 164ef007a8bb0c88b447252b7590e940d95f1561 (diff) | |
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.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 15 |
1 files 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() |
