From a5b6ecd3c82fc95ad3482794a38a00071802c565 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Sat, 25 Oct 2025 13:19:31 +0800 Subject: [PATCH] Fix Symbol.ranges unpacking The Symbol.ranges attribute in kconfiglib returns 4-tuples (low, high, cond, loc), but menuconfig and guiconfig were using the old 3-tuple unpacking pattern, causing ValueError when processing integer/hex symbols with range properties. Changes: - Update all sym.ranges unpacking to handle 4-tuple format - Use underscore (_) for unused location parameter to indicate intent - Standardize on sym.orig_type instead of sym.type for consistency with kconfiglib internals and to avoid potential issues with type transformations --- guiconfig.py | 12 ++++++------ menuconfig.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/guiconfig.py b/guiconfig.py index 9652ec7..24bce83 100755 --- a/guiconfig.py +++ b/guiconfig.py @@ -1844,23 +1844,23 @@ def _check_valid(dialog, entry, sym, s): # Returns True if the string 's' is a well-formed value for 'sym'. # Otherwise, pops up an error and returns False. - if sym.type not in (INT, HEX): + if sym.orig_type not in (INT, HEX): # Anything goes for non-int/hex symbols return True - base = 10 if sym.type == INT else 16 + base = 10 if sym.orig_type == INT else 16 try: int(s, base) except ValueError: messagebox.showerror( "Bad value", - "'{}' is a malformed {} value".format(s, TYPE_TO_STR[sym.type]), + "'{}' is a malformed {} value".format(s, TYPE_TO_STR[sym.orig_type]), parent=dialog, ) entry.focus_set() return False - for low_sym, high_sym, cond in sym.ranges: + for low_sym, high_sym, cond, _ in sym.ranges: if expr_value(cond): low_s = low_sym.str_value high_s = high_sym.str_value @@ -1883,8 +1883,8 @@ def _range_info(sym): # Returns a string with information about the valid range for the symbol # 'sym', or None if 'sym' doesn't have a range - if sym.type in (INT, HEX): - for low, high, cond in sym.ranges: + if sym.orig_type in (INT, HEX): + for low, high, cond, _ in sym.ranges: if expr_value(cond): return "Range: {}-{}".format(low.str_value, high.str_value) diff --git a/menuconfig.py b/menuconfig.py index cd301bd..a8f6278 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -4104,7 +4104,7 @@ def _check_valid(sym, s): _error("'{}' is a malformed {} value".format(s, TYPE_TO_STR[sym.orig_type])) return False - for low_sym, high_sym, cond in sym.ranges: + for low_sym, high_sym, cond, _ in sym.ranges: if expr_value(cond): low_s = low_sym.str_value high_s = high_sym.str_value @@ -4123,7 +4123,7 @@ def _range_info(sym): # 'sym', or None if 'sym' doesn't have a range if sym.orig_type in (INT, HEX): - for low, high, cond in sym.ranges: + for low, high, cond, _ in sym.ranges: if expr_value(cond): return "Range: {}-{}".format(low.str_value, high.str_value)