From dbbac56185fa8bd559f85ab09fd5f9fa741ec785 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 11 Apr 2021 14:54:11 +0200 Subject: [PATCH] Base: do not report C++ exception when converting it to Python exception See https://forum.freecadweb.org/viewtopic.php?f=23&t=56464 --- src/Base/PyObjectBase.h | 2 -- src/Mod/Part/App/OCCError.h | 1 - src/Tools/generateTemplates/templateClassPyExport.py | 6 ------ 3 files changed, 9 deletions(-) diff --git a/src/Base/PyObjectBase.h b/src/Base/PyObjectBase.h index d7d1c0b6e8..593253f89e 100644 --- a/src/Base/PyObjectBase.h +++ b/src/Base/PyObjectBase.h @@ -463,12 +463,10 @@ BaseExport extern PyObject* BaseExceptionFreeCADAbort; #define __PY_CATCH(R) \ catch(Base::AbortException &e) \ { \ - e.ReportException(); \ _Py_ErrorObj(R,Base::BaseExceptionFreeCADAbort,e.getPyObject());\ } \ catch(Base::Exception &e) \ { \ - e.ReportException(); \ auto pye = e.getPyExceptionType(); \ if(!pye) \ pye = Base::BaseExceptionFreeCADError; \ diff --git a/src/Mod/Part/App/OCCError.h b/src/Mod/Part/App/OCCError.h index fbdd98d202..411641858a 100644 --- a/src/Mod/Part/App/OCCError.h +++ b/src/Mod/Part/App/OCCError.h @@ -80,7 +80,6 @@ PartExport extern PyObject* PartExceptionOCCDimensionError; str += " "; \ if (msg) {str += msg;} \ else {str += "No OCCT Exception Message";} \ - Base::Console().Error(str.c_str()); \ _Py_Error(R,Part::PartExceptionOCCError,str.c_str()); \ } \ _PY_CATCH(R) diff --git a/src/Tools/generateTemplates/templateClassPyExport.py b/src/Tools/generateTemplates/templateClassPyExport.py index bc7f60749a..4621d855b3 100644 --- a/src/Tools/generateTemplates/templateClassPyExport.py +++ b/src/Tools/generateTemplates/templateClassPyExport.py @@ -615,13 +615,11 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject } // Please sync the following catch implementation with PY_CATCH catch(Base::AbortException &e) { - e.ReportException(); PyErr_SetObject(Base::BaseExceptionFreeCADAbort,e.getPyObject()); return NULL; } catch(Base::Exception &e) { - e.ReportException(); auto pye = e.getPyExceptionType(); if(!pye) pye = Base::BaseExceptionFreeCADError; @@ -790,13 +788,11 @@ PyObject *@self.export.Name@::_getattr(const char *attr) // __getattr__ functi } // Please sync the following catch implementation with PY_CATCH catch(Base::AbortException &e) { - e.ReportException(); PyErr_SetObject(Base::BaseExceptionFreeCADAbort,e.getPyObject()); return NULL; } catch(Base::Exception &e) { - e.ReportException(); auto pye = e.getPyExceptionType(); if(!pye) pye = Base::BaseExceptionFreeCADError; @@ -852,13 +848,11 @@ int @self.export.Name@::_setattr(const char *attr, PyObject *value) // __setattr } // Please sync the following catch implementation with PY_CATCH catch(Base::AbortException &e) { - e.ReportException(); PyErr_SetObject(Base::BaseExceptionFreeCADAbort,e.getPyObject()); return -1; } catch(Base::Exception &e) { - e.ReportException(); auto pye = e.getPyExceptionType(); if(!pye) pye = Base::BaseExceptionFreeCADError;