summaryrefslogtreecommitdiff
path: root/Objects/genobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r--Objects/genobject.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 88b03c5ef3..9f593382f5 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -822,18 +822,16 @@ PyGen_New(PyFrameObject *f)
int
PyGen_NeedsFinalizing(PyGenObject *gen)
{
- int i;
PyFrameObject *f = gen->gi_frame;
if (f == NULL || f->f_stacktop == NULL)
return 0; /* no frame or empty blockstack == no finalization */
- /* Any block type besides a loop requires cleanup. */
- for (i = 0; i < f->f_iblock; i++)
- if (f->f_blockstack[i].b_type != SETUP_LOOP)
- return 1;
+ /* Any (exception-handling) block type requires cleanup. */
+ if (f->f_iblock > 0)
+ return 1;
- /* No blocks except loops, it's safe to skip finalization. */
+ /* No blocks, it's safe to skip finalization. */
return 0;
}