summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/plugin.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-11-11 12:08:32 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-11-11 12:08:32 (GMT)
commit4140c074a40ec1e1a68b6c2cb040b8746a7c0e34 (patch)
tree554ed8913faf3c43d137a6c5871f9722fd3271d1 /plugins/pychrysalide/plugin.c
parentc301f7e77eaca632a491b5b4417c8e4b9dce2570 (diff)
Printed more details when a Python plugin fails to load.
Diffstat (limited to 'plugins/pychrysalide/plugin.c')
-rw-r--r--plugins/pychrysalide/plugin.c62
1 files changed, 19 insertions, 43 deletions
diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c
index ad77c34..a0822f7 100644
--- a/plugins/pychrysalide/plugin.c
+++ b/plugins/pychrysalide/plugin.c
@@ -978,60 +978,26 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename)
GPythonPlugin *result; /* Structure à retourner */
PyObject *name; /* Chemin d'accès pour Python */
PyObject *module; /* Script Python chargé */
- PyObject *err_type; /* Type d'erreur Python */
- PyObject *err_value; /* Instance Python d'erreur */
- PyObject *err_traceback; /* Trace Python associée */
- PyObject *err_string; /* Description Python d'erreur */
- const char *err_msg; /* Représentation humaine */
PyObject *dict; /* Dictionnaire associé */
PyObject *class; /* Classe à instancier */
PyObject *instance; /* Instance Python du greffon */
name = PyUnicode_FromString(modname);
- if (name == NULL) goto gppn_bad_exit;
+ if (name == NULL) goto bad_exit;
module = PyImport_Import(name);
Py_DECREF(name);
- if (PyErr_Occurred())
- {
- PyErr_Fetch(&err_type, &err_value, &err_traceback);
-
- if (err_value == NULL)
- log_variadic_message(LMT_ERROR,
- _("An unknown error occured when importing '%s'..."), modname);
- else
- {
- err_string = PyObject_Str(err_value);
- err_msg = PyUnicode_AsUTF8(err_string);
-
- log_variadic_message(LMT_ERROR,
- _("An error occured when importing '%s': \"%s\""), modname, err_msg);
-
- Py_DECREF(err_string);
- Py_DECREF(err_value);
-
- }
-
- Py_XDECREF(err_traceback);
- Py_XDECREF(err_type);
-
- Py_XDECREF(module);
-
- module = NULL;
-
- }
-
- if (module == NULL) goto gppn_bad_exit;
+ if (module == NULL) goto no_import;
dict = PyModule_GetDict(module);
class = PyDict_GetItemString(dict, "AutoLoad");
- if (class == NULL) goto gppn_no_class;
- if (!PyType_Check(class->ob_type)) goto gppn_no_class;
+ if (class == NULL) goto no_class;
+ if (!PyType_Check(class->ob_type)) goto no_class;
instance = PyObject_CallFunction(class, NULL);
- if (instance == NULL) goto gppn_no_instance;
+ if (instance == NULL) goto no_instance;
result = G_PYTHON_PLUGIN(pygobject_get(instance));
@@ -1048,13 +1014,23 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename)
return G_PLUGIN_MODULE(result);
- gppn_no_instance:
+ no_instance:
- gppn_no_class:
+ log_pychrysalide_exception(_("An error occured when building the 'AutoLoad' instance"));
- Py_DECREF(module);
+ no_class:
+
+ if (class == NULL)
+ log_pychrysalide_simple_message(LMT_ERROR,
+ _("An error occured when looking for the 'AutoLoad': item not found!"));
+
+ no_import:
+
+ Py_XDECREF(module);
+
+ log_pychrysalide_exception(_("An error occured when importing '%s'"), modname);
- gppn_bad_exit:
+ bad_exit:
return NULL;