+ handle Python's SystemExit exception when running script or macro

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5398 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer
2012-01-11 18:39:27 +00:00
parent 84ed629cb6
commit 5db505d43d
3 changed files with 23 additions and 8 deletions

View File

@@ -242,8 +242,12 @@ void InterpreterSingleton::runFile(const char*pxFileName, bool local)
PyObject *result = PyRun_File(fp, pxFileName, Py_file_input, dict, dict);
fclose(fp);
Py_DECREF(dict);
if (!result)
throw PyException();
if (!result) {
if (PyErr_ExceptionMatches(PyExc_SystemExit))
throw SystemExitException();
else
throw PyException();
}
Py_DECREF(result);
}
else {
@@ -271,8 +275,12 @@ bool InterpreterSingleton::loadModule(const char* psModName)
PyGILStateLocker locker;
module = PP_Load_Module(psModName);
if (!module)
throw PyException();
if (!module) {
if (PyErr_ExceptionMatches(PyExc_SystemExit))
throw SystemExitException();
else
throw PyException();
}
return true;
}