mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
gh-129354: Use PyErr_FormatUnraisable() function (#129523)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable(). Update tests: * test_coroutines * test_exceptions * test_generators * test_struct
This commit is contained in:
parent
dc804ffb2f
commit
a25042e6d2
7 changed files with 42 additions and 17 deletions
|
@ -1445,7 +1445,8 @@ _PyErr_WarnUnawaitedAgenMethod(PyAsyncGenObject *agen, PyObject *method)
|
|||
"coroutine method %R of %R was never awaited",
|
||||
method, agen->ag_qualname) < 0)
|
||||
{
|
||||
PyErr_WriteUnraisable((PyObject *)agen);
|
||||
PyErr_FormatUnraisable("Exception ignored while "
|
||||
"finalizing async generator %R", agen);
|
||||
}
|
||||
PyErr_SetRaisedException(exc);
|
||||
}
|
||||
|
@ -1487,14 +1488,17 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro)
|
|||
}
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_WriteUnraisable(coro);
|
||||
PyErr_FormatUnraisable("Exception ignored while "
|
||||
"finalizing coroutine %R", coro);
|
||||
}
|
||||
|
||||
if (!warned) {
|
||||
if (_PyErr_WarnFormat(coro, PyExc_RuntimeWarning, 1,
|
||||
"coroutine '%S' was never awaited",
|
||||
((PyCoroObject *)coro)->cr_qualname) < 0)
|
||||
{
|
||||
PyErr_WriteUnraisable(coro);
|
||||
PyErr_FormatUnraisable("Exception ignored while "
|
||||
"finalizing coroutine %R", coro);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue