mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
GH-89091: raise RuntimeWarning
for unawaited async generator methods (#104611)
This commit is contained in:
parent
46857d0b2a
commit
7fc542c88d
9 changed files with 96 additions and 2 deletions
|
@ -1365,6 +1365,20 @@ exit:
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
_PyErr_WarnUnawaitedAgenMethod(PyAsyncGenObject *agen, PyObject *method)
|
||||
{
|
||||
PyObject *exc = PyErr_GetRaisedException();
|
||||
if (_PyErr_WarnFormat((PyObject *)agen, PyExc_RuntimeWarning, 1,
|
||||
"coroutine method %R of %R was never awaited",
|
||||
method, agen->ag_qualname) < 0)
|
||||
{
|
||||
PyErr_WriteUnraisable((PyObject *)agen);
|
||||
}
|
||||
PyErr_SetRaisedException(exc);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_PyErr_WarnUnawaitedCoroutine(PyObject *coro)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue