aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-07-06 23:21:04 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-07-07 04:33:24 -0700
commit80392225a61a5baa28ef1f45bfc19b4623d2d188 (patch)
tree8a5f4754aea7d1fa07c9df76efd5bb658ff6c962 /mesonbuild/interpreter.py
parent4fb00ee1d8c79184e3a77f9266e90d42ff595f41 (diff)
downloadmeson-80392225a61a5baa28ef1f45bfc19b4623d2d188.zip
meson-80392225a61a5baa28ef1f45bfc19b4623d2d188.tar.gz
meson-80392225a61a5baa28ef1f45bfc19b4623d2d188.tar.bz2
Raise a MesonException when substituting an invalid value
Avoids throwing a traceback. Also, warn when setting such a value.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 3acb14f..121fdb7 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -276,8 +276,9 @@ class ConfigurationDataHolder(MutableInterpreterObject, ObjectHolder):
def validate_args(self, args, kwargs):
if len(args) == 1 and isinstance(args[0], list) and len(args[0]) == 2:
- mlog.deprecation('''Passing a list as the single argument to configuration_data.set is deprecated.
-This will become a hard error in the future''')
+ mlog.deprecation('Passing a list as the single argument to '
+ 'configuration_data.set is deprecated. This will '
+ 'become a hard error in the future.')
args = args[0]
if len(args) != 2:
@@ -286,6 +287,11 @@ This will become a hard error in the future''')
raise InterpreterException("Can not set values on configuration object that has been used.")
name = args[0]
val = args[1]
+ if not isinstance(val, (int, str)):
+ msg = 'Setting a configuration data value to {!r} is invalid, ' \
+ 'and will fail at configure_file(). If you are using it ' \
+ 'just to store some values, please use a dict instead.'
+ mlog.deprecation(msg.format(val))
desc = kwargs.get('description', None)
if not isinstance(name, str):
raise InterpreterException("First argument to set must be a string.")