Printing unknown kwarg error message no longer crashes the parser.

pull/2179/head
Jussi Pakkanen 7 years ago
parent c8e61f112d
commit 4a766147fb
  1. 8
      mesonbuild/interpreter.py
  2. 14
      mesonbuild/interpreterbase.py
  3. 4
      test cases/frameworks/7 gnome/gir/meson.build

@ -1015,9 +1015,10 @@ class CompilerHolder(InterpreterObject):
return [] return []
ModuleState = namedtuple('ModuleState', [ ModuleState = namedtuple('ModuleState', [
'build_to_src', 'subdir', 'environment', 'project_name', 'project_version', 'build_to_src', 'subdir', 'current_lineno', 'environment', 'project_name',
'backend', 'compilers', 'targets', 'data', 'headers', 'man', 'global_args', 'project_version', 'backend', 'compilers', 'targets', 'data', 'headers',
'project_args', 'build_machine', 'host_machine', 'target_machine']) 'man', 'global_args', 'project_args', 'build_machine', 'host_machine',
'target_machine'])
class ModuleHolder(InterpreterObject): class ModuleHolder(InterpreterObject):
def __init__(self, modname, module, interpreter): def __init__(self, modname, module, interpreter):
@ -1040,6 +1041,7 @@ class ModuleHolder(InterpreterObject):
build_to_src=os.path.relpath(self.interpreter.environment.get_source_dir(), build_to_src=os.path.relpath(self.interpreter.environment.get_source_dir(),
self.interpreter.environment.get_build_dir()), self.interpreter.environment.get_build_dir()),
subdir=self.interpreter.subdir, subdir=self.interpreter.subdir,
current_lineno=self.interpreter.current_lineno,
environment=self.interpreter.environment, environment=self.interpreter.environment,
project_name=self.interpreter.build.project_name, project_name=self.interpreter.build.project_name,
project_version=self.interpreter.build.dep_manifest[self.interpreter.active_projectname], project_version=self.interpreter.build.dep_manifest[self.interpreter.active_projectname],

@ -62,13 +62,19 @@ class permittedKwargs:
def __call__(self, f): def __call__(self, f):
@wraps(f) @wraps(f)
def wrapped(s, node, args, kwargs): def wrapped(s, node_or_state, args, kwargs):
if hasattr(s, 'subdir'):
subdir = s.subdir
lineno = s.current_lineno
elif hasattr(node_or_state, 'subdir'):
subdir = node_or_state.subdir
lineno = node_or_state.current_lineno
for k in kwargs: for k in kwargs:
if k not in self.permitted: if k not in self.permitted:
fname = os.path.join(s.subdir, environment.build_filename) fname = os.path.join(subdir, environment.build_filename)
mlog.warning('''Passed invalid keyword argument "%s" in %s line %d. mlog.warning('''Passed invalid keyword argument "%s" in %s line %d.
This will become a hard error in the future.''' % (k, fname, s.current_lineno)) This will become a hard error in the future.''' % (k, fname, lineno))
return f(s, node, args, kwargs) return f(s, node_or_state, args, kwargs)
return wrapped return wrapped

@ -30,6 +30,10 @@ gnome.generate_gir(
dependencies : [fake_dep, dep1_dep], dependencies : [fake_dep, dep1_dep],
install : true, install : true,
build_by_default : true, build_by_default : true,
# Test that unknown kwargs do not crash the parser.
# Unknown kwargs will eventually become a hard error.
# Once that happens remove this.
unknown_kwarg : true,
) )
test('gobject introspection/c', girexe) test('gobject introspection/c', girexe)

Loading…
Cancel
Save