Skip to content

Commit

Permalink
event: Replace _PyGen_FetchStopIterationValue in Python 3.13+
Browse files Browse the repository at this point in the history
  • Loading branch information
rdb committed Aug 5, 2023
1 parent 5c0eb72 commit 043417b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/event/pythonTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,17 @@ do_python_task() {
Py_DECREF(_generator);
_generator = nullptr;

#if PY_VERSION_HEX >= 0x03030000
#if PY_VERSION_HEX >= 0x030D0000 // Python 3.13
// Python 3.13 does not support _PyGen_FetchStopIterationValue anymore.
if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
PyObject *exc = PyErr_GetRaisedException();
result = ((PyStopIterationObject *)exc)->value;
if (result == nullptr) {
result = Py_None;
}
Py_INCREF(result);
Py_DECREF(exc);
#elif PY_VERSION_HEX >= 0x03030000
if (_PyGen_FetchStopIterationValue(&result) == 0) {
#else
if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
Expand Down

0 comments on commit 043417b

Please sign in to comment.