summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2018-02-14 12:25:02 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2018-02-14 12:28:25 +0000
commit1b664f7170eef19b0a585cfbafa5b17a28349407 (patch)
treedcff4709e1ba6c0167c2fa936eda17d9ce94085b
parent955b184ea1a21bc3b0d81a1f6f7103b152157a58 (diff)
downloadbuildstream-sam/plugin-error.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'
-rw-r--r--buildstream/_plugincontext.py5
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'