summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2018-01-29 19:31:47 (GMT)
committerGitHub <noreply@github.com>2018-01-29 19:31:47 (GMT)
commit2a2270db9be9bdac5ffd2d50929bf905e7391a06 (patch)
tree4c45678f9e26ccc66843ed79a7467fabe03cf6b6 /Objects
parentb647d7039d396b1da71ab33b101a78b53d4e6834 (diff)
downloadcpython-2a2270db9be9bdac5ffd2d50929bf905e7391a06.zip
cpython-2a2270db9be9bdac5ffd2d50929bf905e7391a06.tar.gz
cpython-2a2270db9be9bdac5ffd2d50929bf905e7391a06.tar.bz2
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')
-rw-r--r--Objects/genobject.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 1fdb57c..88b03c5 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);