diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-02-22 23:33:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-22 23:33:30 +0200 |
commit | 520b7ae27e39d1c77ea74ccd1b184d7cb43f9dcb (patch) | |
tree | 8a661515a3574b0d79ea2024a3b92646dd7ee837 /Objects/genobject.c | |
parent | 4af8fd561433826ac897c55e41a087a5c5dbacf3 (diff) | |
download | cpython-git-520b7ae27e39d1c77ea74ccd1b184d7cb43f9dcb.tar.gz |
bpo-17611. Move unwinding of stack for "pseudo exceptions" from interpreter to compiler. (GH-5006)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 10 |
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; } |