diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-01-03 22:32:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-03 22:32:40 +0200 |
commit | 65f78a722ad0f8ab260e7cf24636ef38e8bd957f (patch) | |
tree | 76024acbc0c7d90e8edd69ad07c79124de622a46 /mesonbuild/interpreterbase.py | |
parent | c814f1145bc521efd0a46b033751a6f844d24df5 (diff) | |
parent | bcc95d7dd703779228ec81b92197e010d0e5a1ea (diff) | |
download | meson-65f78a722ad0f8ab260e7cf24636ef38e8bd957f.zip meson-65f78a722ad0f8ab260e7cf24636ef38e8bd957f.tar.gz meson-65f78a722ad0f8ab260e7cf24636ef38e8bd957f.tar.bz2 |
Merge pull request #2856 from jon-turney/warning-location
Consolidate warning location formatting
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 |