From dc91aad42009f739f9e6d73221efc071626c28a3 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 9 May 2018 15:08:52 +0200 Subject: [PATCH] args flattening: preserve configuration_data.set behaviour It seems that some projects relied on the previously buggy behaviour of accepting a 2-element list as the single argument to configuration_data.set(). Special-case this behaviour, and emit a deprecation message. --- mesonbuild/interpreter.py | 6 ++++++ test cases/common/198 args flattening/meson.build | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 7324f6760..828ab35ac 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -211,6 +211,12 @@ class ConfigurationDataHolder(MutableInterpreterObject, ObjectHolder): self.used = True def validate_args(self, args, kwargs): + if len(args) == 1 and isinstance(args[0], list) and len(args[0]) == 2: + mlog.log(mlog.red('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: raise InterpreterException("Configuration set requires 2 arguments.") if self.used: diff --git a/test cases/common/198 args flattening/meson.build b/test cases/common/198 args flattening/meson.build index 1c7467d3f..6da2e8f25 100644 --- a/test cases/common/198 args flattening/meson.build +++ b/test cases/common/198 args flattening/meson.build @@ -21,3 +21,9 @@ assert(arr == ['bar', 'baz'], 'configuration_data.get with array fallback is bro arr = meson.get_cross_property('does-not-exist', ['bar', 'baz']) assert(arr == ['bar', 'baz'], 'meson.get_cross_property with array fallback is broken') + +# Test deprecated behaviour + +conf.set(['foo', 'bar']) + +message(conf.get('foo'))