From 37abc22cf8d26fa3f7e282a1ee50a2a129d5a295 Mon Sep 17 00:00:00 2001
From: "Daniel M. Pelt" <D.M.Pelt@cwi.nl>
Date: Mon, 20 Jul 2015 11:26:39 +0200
Subject: Always log Python errors when importing/creating plugins

---
 src/PluginAlgorithm.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

(limited to 'src')

diff --git a/src/PluginAlgorithm.cpp b/src/PluginAlgorithm.cpp
index a118f54..d6cf731 100644
--- a/src/PluginAlgorithm.cpp
+++ b/src/PluginAlgorithm.cpp
@@ -173,13 +173,19 @@ PyObject * getClassFromString(std::string str){
     std::vector<std::string> items;
     boost::split(items, str, boost::is_any_of("."));
     PyObject *pyclass = PyImport_ImportModule(items[0].c_str());
-    if(pyclass==NULL) return NULL;
+    if(pyclass==NULL){
+        logPythonError();
+        return NULL;
+    }
     PyObject *submod = pyclass;
     for(unsigned int i=1;i<items.size();i++){
         submod = PyObject_GetAttrString(submod,items[i].c_str());
         Py_DECREF(pyclass);
         pyclass = submod;
-        if(pyclass==NULL) return NULL;
+        if(pyclass==NULL){
+            logPythonError();
+            return NULL;
+        }
     }
     return pyclass;
 }
@@ -194,8 +200,6 @@ CPluginAlgorithm * CPluginAlgorithmFactory::getPlugin(std::string name){
         if(pyclass!=NULL){
             alg = new CPluginAlgorithm(pyclass);
             Py_DECREF(pyclass);
-        }else{
-            logPythonError();
         }
     }else{
         alg = new CPluginAlgorithm(className);
-- 
cgit v1.2.3