Base: Improve Python exception handling

If the Python profiler is activated then transporting the dict as
exception object is broken where InteractiveInterpreter::runCode()
fails to restore it.
To fix the problem use Exception::setPyException() instead inside
the macto PY_CATCH and the generated wrapper code.

This also improves exception handling in command line mode.
This commit is contained in:
wmayer
2025-01-06 15:14:02 +01:00
committed by Benjamin Nauck
parent e0027daf3b
commit 2c60e83f25
2 changed files with 12 additions and 23 deletions

View File

@@ -446,12 +446,10 @@ BaseExport extern PyObject* PyExc_FC_AbortIOException;
#define PY_TRY try
#define __PY_CATCH(R) \
catch(Base::Exception &e) \
catch(const Base::Exception &e) \
{ \
auto pye = e.getPyExceptionType(); \
if(!pye) \
pye = Base::PyExc_FC_GeneralError; \
_Py_ErrorObj(R,pye,e.getPyObject()); \
e.setPyException(); \
R; \
} \
catch(const std::exception &e) \
{ \