summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2023-05-26 11:23:29 (GMT)
committerGitHub <noreply@github.com>2023-05-26 11:23:29 (GMT)
commit7fc542c88dc8a09d71006a6240943407b83229d0 (patch)
tree7a07b24e2fec790d9d4fa7bf7eef3779f46cdcf3 /Python
parent46857d0b2a2ac6aeb6dcce2bf2c92ddf4abe7496 (diff)
downloadcpython-7fc542c88dc8a09d71006a6240943407b83229d0.zip
cpython-7fc542c88dc8a09d71006a6240943407b83229d0.tar.gz
cpython-7fc542c88dc8a09d71006a6240943407b83229d0.tar.bz2
GH-89091: raise `RuntimeWarning` for unawaited async generator methods (#104611)
Diffstat (limited to 'Python')
-rw-r--r--Python/_warnings.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index dec6586..54fa5c5 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -1366,6 +1366,20 @@ exit:
}
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)
{
/* First, we attempt to funnel the warning through