[Python-checkins] bpo-32591: Fix PyExc_WarnFormat call (follow-up commit) (#5263)
Yury Selivanov
webhook-mailer at python.org
Sun Jan 21 20:47:11 EST 2018
https://github.com/python/cpython/commit/3510334361d6d39aad89e4e0d9bccd0695668583
commit: 3510334361d6d39aad89e4e0d9bccd0695668583
branch: master
author: Yury Selivanov <yury at magic.io>
committer: GitHub <noreply at github.com>
date: 2018-01-21T20:47:04-05:00
summary:
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.
files:
M Python/_warnings.c
diff --git a/Python/_warnings.c b/Python/_warnings.c
index c3417cccb17..20ba7a16616 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);
}
}
More information about the Python-checkins
mailing list