From 520b7ae27e39d1c77ea74ccd1b184d7cb43f9dcb Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 22 Feb 2018 23:33:30 +0200 Subject: bpo-17611. Move unwinding of stack for "pseudo exceptions" from interpreter to compiler. (GH-5006) Co-authored-by: Mark Shannon Co-authored-by: Antoine Pitrou --- Objects/genobject.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Objects/genobject.c') 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; } -- cgit v1.2.1