GH-89091: raise RuntimeWarning for unawaited async generator methods (#104611)

This commit is contained in:
Kumar Aditya 2023-05-26 16:53:29 +05:30 committed by GitHub
parent 46857d0b2a
commit 7fc542c88d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 96 additions and 2 deletions

View file

@ -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)
{