From b253eaa51af2be8e5419837276feab3e3b6ad1b2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 27 Jul 2024 14:29:14 +0200 Subject: [PATCH] Including more GeneratorExit and StopAsyncIteration in the ignored exceptions for Python --- src/pya/pya/pya.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pya/pya/pya.cc b/src/pya/pya/pya.cc index 89ae80c54..5f177fa56 100644 --- a/src/pya/pya/pya.cc +++ b/src/pya/pya/pya.cc @@ -684,7 +684,11 @@ PythonInterpreter::trace_func (PyFrameObject *frame, int event, PyObject *arg) exc_value = PythonPtr (PyTuple_GetItem (arg, 1)); } - if (exc_type && exc_type.get () != PyExc_StopIteration) { +#if PY_VERSION_HEX >= 0x03050000 + if (exc_type && exc_type.get () != PyExc_StopIteration && exc_type.get () != PyExc_GeneratorExit && exc_type.get () != PyExc_StopAsyncIteration) { +#else + if (exc_type && exc_type.get () != PyExc_StopIteration && exc_type.get () != PyExc_GeneratorExit) { +#endif // If the next exception shall be ignored, do so if (m_ignore_next_exception) {