Skip to content

Commit

Permalink
interpreterbase: Add disabler exception for get_variable method
Browse files Browse the repository at this point in the history
Add an exception to the disabler check to allow objects with a `get_variable`
method to not always pick a disabler if their arguments contain one. This
mimics the behaviour already in place for calls to function, which has a set
of excepted functions.

Fixes #13717
  • Loading branch information
amcn committed Oct 11, 2024
1 parent 7396839 commit c91b8ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mesonbuild/interpreterbase/interpreterbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def method_call(self, node: mparser.MethodNode) -> T.Optional[InterpreterObject]
method_name = node.name.value
(h_args, h_kwargs) = self.reduce_arguments(node.args)
(args, kwargs) = self._unholder_args(h_args, h_kwargs)
if is_disabled(args, kwargs):
if is_disabled(args, kwargs) and method_name != 'get_variable':
return Disabler()
if not isinstance(obj, InterpreterObject):
raise InvalidArguments(f'{object_display_name} is not callable.')
Expand Down
11 changes: 11 additions & 0 deletions test cases/common/280 subproject get_variable disabler/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://github.com/mesonbuild/meson/issues/13717

project('foo', 'c')

bar_subproj = subproject('bar')
bar_dep = bar_subproj.get_variable('bar_dep', disabler())

if is_disabler(bar_dep)
error('bar_dep is a disabler')
endif

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project('bar', 'c')
bar_dep = declare_dependency()

0 comments on commit c91b8ba

Please sign in to comment.