diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2017-12-31 17:33:50 +0000 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2018-01-01 13:21:01 +0000 |
commit | bcc95d7dd703779228ec81b92197e010d0e5a1ea (patch) | |
tree | 9454e80529e60129ec79604046987bd214c4c3c8 /mesonbuild/interpreterbase.py | |
parent | f85fde743a292e24c9aed81c23f6af466054aee3 (diff) | |
download | meson-bcc95d7dd703779228ec81b92197e010d0e5a1ea.zip meson-bcc95d7dd703779228ec81b92197e010d0e5a1ea.tar.gz meson-bcc95d7dd703779228ec81b92197e010d0e5a1ea.tar.bz2 |
Use location formatting in mlog.warning() for invalid kwarg warning
This already reports the location (in a slightly different format), but
using mlog.warning() will make it easier if we want to change the location
format in future.
Diffstat (limited to 'mesonbuild/interpreterbase.py')
-rw-r--r-- | mesonbuild/interpreterbase.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 91f4bd3..9dc6b0f 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -18,7 +18,7 @@ from . import mparser, mesonlib, mlog from . import environment, dependencies -import os, copy, re +import os, copy, re, types from functools import wraps # Decorators for method calls. @@ -63,17 +63,19 @@ class permittedKwargs: def __call__(self, f): @wraps(f) def wrapped(s, node_or_state, args, kwargs): + loc = types.SimpleNamespace() if hasattr(s, 'subdir'): - subdir = s.subdir - lineno = s.current_lineno + loc.subdir = s.subdir + loc.lineno = s.current_lineno elif hasattr(node_or_state, 'subdir'): - subdir = node_or_state.subdir - lineno = node_or_state.current_lineno + loc.subdir = node_or_state.subdir + loc.lineno = node_or_state.current_lineno + else: + loc = None for k in kwargs: if k not in self.permitted: - fname = os.path.join(subdir, environment.build_filename) - mlog.warning('''Passed invalid keyword argument "%s" in %s line %d. -This will become a hard error in the future.''' % (k, fname, lineno)) + mlog.warning('''Passed invalid keyword argument "{}"'''.format(k), location=loc) + mlog.warning('This will become a hard error in the future.') return f(s, node_or_state, args, kwargs) return wrapped |