Skip to content

Commit

Permalink
Fix missing reference increase in backport of PyErr_SetRaisedException
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity committed Aug 4, 2024
1 parent b59acac commit b09a8c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/_pyawaitable/backport.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ PyErr_GetRaisedException(void)
void
PyErr_SetRaisedException(PyObject *err)
{
PyErr_Restore((PyObject *) Py_TYPE(err), err, NULL);
// NOTE: We need to incref the type object here, even though
// this function steals a reference to err.
PyErr_Restore(Py_NewRef((PyObject *) Py_TYPE(err)), err, NULL);
}

#endif
Expand Down
3 changes: 0 additions & 3 deletions tests/test_awaitable.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ def cb_err(awaitable_inner: pyawaitable.PyAwaitable, err: Exception) -> int:

assert called is True

"""
@limit_leaks(LEAK_LIMIT)
@pytest.mark.asyncio
async def test_await_cb_err_norestore():
Expand Down Expand Up @@ -444,4 +442,3 @@ async def coro(): ...

add_await(awaitable, coro(), cb, awaitcallback_err(0))
await awaitable
"""

0 comments on commit b09a8c3

Please sign in to comment.