+ 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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user