diff options
author | Yury Selivanov <yury@magic.io> | 2018-01-29 14:31:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 14:31:47 -0500 |
commit | 2a2270db9be9bdac5ffd2d50929bf905e7391a06 (patch) | |
tree | 4c45678f9e26ccc66843ed79a7467fabe03cf6b6 /Objects/genobject.c | |
parent | bpo-32707: Fix warnings in hamt.c (#5430) (diff) | |
download | cpython-2a2270db9be9bdac5ffd2d50929bf905e7391a06.tar.gz cpython-2a2270db9be9bdac5ffd2d50929bf905e7391a06.tar.bz2 cpython-2a2270db9be9bdac5ffd2d50929bf905e7391a06.zip |
bpo-32703: Fix coroutine resource warning in case where there's an error (GH-5410)
The commit removes one unnecessary "if" clause in genobject.c. That "if" clause was masking un-awaited coroutines warnings just to make writing unittests more convenient.
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index 1fdb57c8ce8..88b03c5ef31 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -44,9 +44,10 @@ _PyGen_Finalize(PyObject *self) PyObject *res = NULL; PyObject *error_type, *error_value, *error_traceback; - if (gen->gi_frame == NULL || gen->gi_frame->f_stacktop == NULL) + if (gen->gi_frame == NULL || gen->gi_frame->f_stacktop == NULL) { /* Generator isn't paused, so no need to close */ return; + } if (PyAsyncGen_CheckExact(self)) { PyAsyncGenObject *agen = (PyAsyncGenObject*)self; @@ -75,18 +76,18 @@ _PyGen_Finalize(PyObject *self) issue a RuntimeWarning. */ if (gen->gi_code != NULL && ((PyCodeObject *)gen->gi_code)->co_flags & CO_COROUTINE && - gen->gi_frame->f_lasti == -1) { - if (!error_value) { - _PyErr_WarnUnawaitedCoroutine((PyObject *)gen); - } + gen->gi_frame->f_lasti == -1) + { + _PyErr_WarnUnawaitedCoroutine((PyObject *)gen); } else { res = gen_close(gen, NULL); } if (res == NULL) { - if (PyErr_Occurred()) + if (PyErr_Occurred()) { PyErr_WriteUnraisable(self); + } } else { Py_DECREF(res); |