Skip to content

Commit

Permalink
assert function name in traceback, shutdown engine if not an exceptio…
Browse files Browse the repository at this point in the history
…n is passed

Signed-off-by: Gajowniczek, Artur <[email protected]>
  • Loading branch information
argaj committed Jul 16, 2024
1 parent 34a1db1 commit 3da3626
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cpp/csp/python/PyAdapterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion csp/tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3da3626

Please sign in to comment.