diff options
| -rw-r--r-- | mesonbuild/interpreter/interpreter.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 04de6fc6b..185bb07ee 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -1069,6 +1069,9 @@ class Interpreter(InterpreterBase, HoldableObject): if optname_regex.search(optname.split('.', maxsplit=1)[-1]) is not None: raise InterpreterException(f'Invalid option name {optname!r}') + # Will be None only if the value comes from the default + value_object: T.Optional[options.AnyOptionType] + try: optkey = options.OptionKey(optname, self.subproject) value_object, value = self.coredata.optstore.get_value_object_and_value_for(optkey) @@ -1076,7 +1079,14 @@ class Interpreter(InterpreterBase, HoldableObject): if self.coredata.optstore.is_base_option(optkey): # Due to backwards compatibility return the default # option for base options instead of erroring out. - return self.coredata.optstore.get_default_for_b_option(optkey) + # + # TODO: This will have issues if we expect to return a user FeatureOption + # Of course, there's a bit of a layering violation here in + # that we return a UserFeatureOption, but otherwise the held value + # We probably need a lower level feature thing, or an enum + # instead of strings + value = self.coredata.optstore.get_default_for_b_option(optkey) + value_object = None else: if self.subproject: raise MesonException(f'Option {optname} does not exist for subproject {self.subproject}.') @@ -1087,7 +1097,7 @@ class Interpreter(InterpreterBase, HoldableObject): ocopy.value = value return ocopy elif optname == 'b_sanitize': - assert isinstance(value_object, options.UserStringArrayOption) + assert value_object is None or isinstance(value_object, options.UserStringArrayOption) # To ensure backwards compatibility this always returns a string. # We may eventually want to introduce a new "format" kwarg that # allows the user to modify this behaviour, but for now this is @@ -1096,7 +1106,7 @@ class Interpreter(InterpreterBase, HoldableObject): return 'none' return ','.join(sorted(value)) - if isinstance(value_object.value, str): + if isinstance(value, str): return P_OBJ.OptionString(value, f'{{{optname}}}') return value |
