diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2018-02-14 12:25:02 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2018-02-14 12:28:25 +0000 |
commit | 1b664f7170eef19b0a585cfbafa5b17a28349407 (patch) | |
tree | dcff4709e1ba6c0167c2fa936eda17d9ce94085b /buildstream/_plugincontext.py | |
parent | 955b184ea1a21bc3b0d81a1f6f7103b152157a58 (diff) | |
download | buildstream-1b664f7170eef19b0a585cfbafa5b17a28349407.tar.gz |
_plugincontext.py: Fix unhandled exception if plugin is not foundsam/plugin-error
This fixes an AttributeError triggered if we try to import a plugin from
a package which is installed but does not contain that plugin.
Before:
[--:--:--] START Resolving pipeline
Traceback (most recent call last):
...
AttributeError: 'NoneType' object has no attribute 'dist'
After:
[--:--:--] START Resolving pipeline
[00:00:00] FAILURE Resolving pipeline
Error loading pipeline: Pip package buildstream-external does not contain a plugin named 'nonexistant-plugin'
Diffstat (limited to 'buildstream/_plugincontext.py')
-rw-r--r-- | buildstream/_plugincontext.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/buildstream/_plugincontext.py b/buildstream/_plugincontext.py index 0e1231e63..264adcb79 100644 --- a/buildstream/_plugincontext.py +++ b/buildstream/_plugincontext.py @@ -92,6 +92,11 @@ class PluginContext(): except pkg_resources.DistributionNotFound as e: raise PluginError("Failed to load {} plugin '{}': {}" .format(self.base_type.__name__, kind, e)) from e + + if package is None: + raise PluginError("Pip package {} does not contain a plugin named '{}'" + .format(package_name, kind)) + location = package.dist.get_resource_filename( pkg_resources._manager, package.module_name.replace('.', os.sep) + '.py' |