Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3510334

Browse files
authored
bpo-32591: Fix PyExc_WarnFormat call (follow-up commit) (#5263)
The previous version was correct in terms of behaviour, but checking the return value of PyErr_WarnFormat allows to avoid calling PyErr_Occurred and silences the coverity alarm.
1 parent a4afcdf commit 3510334

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Python/_warnings.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,11 +1191,10 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro)
11911191
PyErr_WriteUnraisable(coro);
11921192
}
11931193
if (!warned) {
1194-
PyErr_WarnFormat(PyExc_RuntimeWarning, 1,
1195-
"coroutine '%.50S' was never awaited",
1196-
((PyCoroObject *)coro)->cr_qualname);
1197-
/* Maybe *that* got converted into an exception */
1198-
if (PyErr_Occurred()) {
1194+
if (PyErr_WarnFormat(PyExc_RuntimeWarning, 1,
1195+
"coroutine '%.50S' was never awaited",
1196+
((PyCoroObject *)coro)->cr_qualname) < 0)
1197+
{
11991198
PyErr_WriteUnraisable(coro);
12001199
}
12011200
}

0 commit comments

Comments
 (0)