From c69a4aee1eb8f78770d59afec6dd12ebea9bfbd1 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 14 Aug 2017 15:54:07 +0300 Subject: [PATCH] Store current line number so it can be printed in warning messages. Closes #2181. --- mesonbuild/interpreterbase.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 213b2bb00..c0755413e 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -65,7 +65,9 @@ class permittedKwargs: def wrapped(s, node, args, kwargs): for k in kwargs: if k not in self.permitted: - mlog.warning('Passed invalid keyword argument "%s". This will become a hard error in the future.' % k) + fname = os.path.join(s.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, s.current_lineno)) return f(s, node, args, kwargs) return wrapped @@ -101,6 +103,7 @@ class InterpreterBase: self.subdir = subdir self.variables = {} self.argument_depth = 0 + self.current_lineno = -1 def load_root_meson_file(self): mesonfile = os.path.join(self.source_root, self.subdir, environment.build_filename) @@ -151,6 +154,7 @@ class InterpreterBase: while i < len(statements): cur = statements[i] try: + self.current_lineno = cur.lineno self.evaluate_statement(cur) except Exception as e: if not(hasattr(e, 'lineno')):