diff options
author | Yury Selivanov <yury@magic.io> | 2018-01-22 01:47:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-22 01:47:04 (GMT) |
commit | 3510334361d6d39aad89e4e0d9bccd0695668583 (patch) | |
tree | a958b198d0afe94ed7b9098ead6e19eef89aa55a /Python/_warnings.c | |
parent | a4afcdfa55ddffa4b9ae3b0cf101628c7bff4102 (diff) | |
download | cpython-3510334361d6d39aad89e4e0d9bccd0695668583.zip cpython-3510334361d6d39aad89e4e0d9bccd0695668583.tar.gz cpython-3510334361d6d39aad89e4e0d9bccd0695668583.tar.bz2 |
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.
Diffstat (limited to 'Python/_warnings.c')
-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); } } |