From 3f63827527e1f9a6175e3457a0a0902825d4b79e Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 9 Mar 2022 12:47:00 -0800 Subject: [PATCH] modules/pkgconfig: ensure "name" is not None The name can be None if a library is not passed as a positional argument, and the name keyword argument is not provided. We shouldn't allow that to happen. --- mesonbuild/modules/pkgconfig.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index a113d1337..aeb77c6e1 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -615,8 +615,14 @@ class PkgConfigModule(ExtensionModule): install_dir = mainlib.get_custom_install_dir() if install_dir and isinstance(install_dir[0], str): default_install_dir = os.path.join(install_dir[0], 'pkgconfig') - elif kwargs['version'] is None: - FeatureNew.single_use('pkgconfig.generate implicit version keyword', '0.46.0', state.subproject) + else: + if kwargs['version'] is None: + FeatureNew.single_use('pkgconfig.generate implicit version keyword', '0.46.0', state.subproject) + if kwargs['name'] is None: + raise build.InvalidArguments( + 'pkgconfig.generate: if a library is not passed as a ' + 'positional argument, the name keyword argument is ' + 'required.') dataonly = kwargs['dataonly'] if dataonly: @@ -629,6 +635,7 @@ class PkgConfigModule(ExtensionModule): subdirs = kwargs['subdirs'] or default_subdirs version = kwargs['version'] if kwargs['version'] is not None else default_version name = kwargs['name'] if kwargs['name'] is not None else default_name + assert isinstance(name, str), 'for mypy' filebase = kwargs['filebase'] if kwargs['filebase'] is not None else name description = kwargs['description'] if kwargs['description'] is not None else default_description url = kwargs['url']