An ignorable exception for plugins

master
Yevgen Muntyan 2008-09-01 01:16:14 -05:00
parent 1eb63773c9
commit 14a38ee78d
2 changed files with 34 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include "pygobject.h"
#include <string.h>
#include "moopython/moopython-loader.h"
#include "mooutils/mooutils-misc.h"
@ -131,6 +132,32 @@ do_load_file (const char *path)
if (!mod)
{
if (PyErr_ExceptionMatches (PyExc_Exception))
{
PyObject *type, *value, *traceback;
PyObject *r;
char *s;
PyErr_Fetch (&type, &value, &traceback);
PyErr_NormalizeException (&type, &value, &traceback);
r = PyObject_Repr (value);
s = r ? PyString_AsString (r) : NULL;
if (s && strcmp (s, "PluginWontLoad") == 0)
{
Py_XDECREF (r);
Py_XDECREF (type);
Py_XDECREF (value);
Py_XDECREF (traceback);
goto out;
}
Py_XDECREF (r);
PyErr_Restore(type, value, traceback);
}
g_warning ("error when loading file '%s'", path);
PyErr_Print ();
goto out;
}

View File

@ -21,6 +21,13 @@ from _moo_edit import *
def edit_class_add_action(cls, action_id, action_class):
_edit._edit_class_add_action(cls, action_id, action_class)
class _PluginWontLoad(Exception):
def __repr__(self):
return 'PluginWontLoad'
def cancel_plugin_loading():
raise _PluginWontLoad()
#class _UIInfo(object):
#def __init__(self, parent, action, name=None, index=-1):
#self.parent = parent