From d591e6c24c19c42e56b6824a28a76efd55fcd090 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 5 Mar 2025 13:07:09 -0800 Subject: [PATCH] fixup! options: merge set_value and set_option --- mesonbuild/options.py | 7 +++++-- unittests/platformagnostictests.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mesonbuild/options.py b/mesonbuild/options.py index 6748f9b94c04..60d0ce938845 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -950,9 +950,12 @@ def set_option(self, key: OptionKey, new_value: ElementaryOptionValues, first_in assert isinstance(prefix, str), 'for mypy' new_value = self.sanitize_dir_option_value(prefix, key, new_value) - opt = self.get_value_object_for(key) + try: + opt = self.get_value_object_for(key) + except KeyError: + opt = None if opt is None: - raise MesonException(f'Unknown options: {key!s} not found.') + raise MesonException(f'Unknown options: "{key!s}" not found.') if opt.deprecated is True: mlog.deprecation(f'Option {key.name!r} is deprecated') diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py index cb6a931fc602..4480e8b31c39 100644 --- a/unittests/platformagnostictests.py +++ b/unittests/platformagnostictests.py @@ -451,7 +451,7 @@ def test_configure_removed_option(self) -> None: f.write(line) with self.assertRaises(subprocess.CalledProcessError) as e: self.setconf('-Dneg_int_opt=0') - self.assertIn('Unknown options: "neg_int_opt"', e.exception.stdout) + self.assertIn('Unknown options: ":neg_int_opt"', e.exception.stdout) def test_configure_option_changed_constraints(self) -> None: """Changing the constraints of an option without reconfiguring should work."""