From 3da36260b92a23ae41c233c4943c28e144ce77b6 Mon Sep 17 00:00:00 2001 From: "Gajowniczek, Artur" Date: Tue, 16 Jul 2024 08:02:59 -0400 Subject: [PATCH] assert function name in traceback, shutdown engine if not an exception is passed Signed-off-by: Gajowniczek, Artur --- cpp/csp/python/PyAdapterManager.cpp | 9 ++++++--- csp/tests/test_engine.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cpp/csp/python/PyAdapterManager.cpp b/cpp/csp/python/PyAdapterManager.cpp index 842483aa2..2a22276a6 100644 --- a/cpp/csp/python/PyAdapterManager.cpp +++ b/cpp/csp/python/PyAdapterManager.cpp @@ -77,9 +77,12 @@ static PyObject * PyAdapterManager_PyObject_shutdown_engine( PyAdapterManager_Py return NULL; if( !PyExceptionInstance_Check( pyException ) ) - CSP_THROW( TypeError, "Expected Exception object as argument for shutdown_engine: got " << Py_TYPE( pyException ) -> tp_name ); - - self -> manager -> rootEngine() -> shutdown( std::make_exception_ptr( PythonPassthrough( pyException ) ) ); + { + std::string desc = "Expected Exception object as argument for shutdown_engine: got " + std::string( Py_TYPE( pyException ) -> tp_name ); + self -> manager -> rootEngine() -> shutdown( std::make_exception_ptr( csp::Exception( "TypeError", desc ) ) ); + } + else + self -> manager -> rootEngine() -> shutdown( std::make_exception_ptr( PythonPassthrough( pyException ) ) ); CSP_RETURN_NONE; } diff --git a/csp/tests/test_engine.py b/csp/tests/test_engine.py index d619ac5f8..f02e32f6f 100644 --- a/csp/tests/test_engine.py +++ b/csp/tests/test_engine.py @@ -846,7 +846,7 @@ def graph(): except IndexError: tb = traceback.format_exc() - self.assertTrue("[].pop()" in tb) + self.assertTrue("[].pop()" in tb and 'process_next_sim_timeslice' in tb) def test_feedback(self): # Dummy example