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.
This commit is contained in:
Yury Selivanov 2018-01-21 20:47:04 -05:00 committed by GitHub
parent a4afcdfa55
commit 3510334361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -1191,11 +1191,10 @@ _PyErr_WarnUnawaitedCoroutine(PyObject *coro)
PyErr_WriteUnraisable(coro);
}
if (!warned) {
PyErr_WarnFormat(PyExc_RuntimeWarning, 1,
if (PyErr_WarnFormat(PyExc_RuntimeWarning, 1,
"coroutine '%.50S' was never awaited",
((PyCoroObject *)coro)->cr_qualname);
/* Maybe *that* got converted into an exception */
if (PyErr_Occurred()) {
((PyCoroObject *)coro)->cr_qualname) < 0)
{
PyErr_WriteUnraisable(coro);
}
}