Fix Python exception handling

This commit is contained in:
wmayer 2013-07-19 12:27:44 +02:00
parent a882476c25
commit a5d9d6312d
2 changed files with 7 additions and 3 deletions

View File

@ -71,12 +71,16 @@ PyException::PyException(void)
_stackTrace = PP_last_error_trace; /* exception traceback text */
// This should be done in the constructor because when doing
// in the destructor it's not always clear when it is called
// and thus may clear a Python exception when it should not.
PyGILStateLocker locker;
PyErr_Clear(); // must be called to keep Python interpreter in a valid state (Werner)
}
PyException::~PyException() throw()
{
PyGILStateLocker locker;
PyErr_Clear(); // must be called to keep Python interpreter in a valid state (Werner)
}
void PyException::ReportException (void) const

View File

@ -60,7 +60,7 @@ void AppCompleteExport initComplete()
try {
Base::Interpreter().loadModule("Draft");
}
catch (const Base::PyException& e) {
catch (const Base::Exception& e) {
// If called from console then issue a message but don't stop with an error
PySys_WriteStdout("Import error: %s\n", e.what());
}