diff options
-rw-r--r-- | Python/_warnings.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index c3417cc..20ba7a1 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -1191,11 +1191,10 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro) PyErr_WriteUnraisable(coro); } if (!warned) { - PyErr_WarnFormat(PyExc_RuntimeWarning, 1, - "coroutine '%.50S' was never awaited", - ((PyCoroObject *)coro)->cr_qualname); - /* Maybe *that* got converted into an exception */ - if (PyErr_Occurred()) { + if (PyErr_WarnFormat(PyExc_RuntimeWarning, 1, + "coroutine '%.50S' was never awaited", + ((PyCoroObject *)coro)->cr_qualname) < 0) + { PyErr_WriteUnraisable(coro); } } |