diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 548265d98..812b7c625 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -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 diff --git a/src/Mod/Complete/App/AppComplete.cpp b/src/Mod/Complete/App/AppComplete.cpp index 057e8296e..2385ff17b 100644 --- a/src/Mod/Complete/App/AppComplete.cpp +++ b/src/Mod/Complete/App/AppComplete.cpp @@ -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()); }