diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-05-10 12:36:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-10 12:36:08 (GMT) |
commit | 7c6b7ade8df35355484d3944779fe35dcc560aab (patch) | |
tree | bd57dc5a2ef5082cae83b22b14495b547b483c27 /Python/compile.c | |
parent | eef47d5bc79469c2d5328d6f5a9732e44a49dd5a (diff) | |
download | cpython-7c6b7ade8df35355484d3944779fe35dcc560aab.zip cpython-7c6b7ade8df35355484d3944779fe35dcc560aab.tar.gz cpython-7c6b7ade8df35355484d3944779fe35dcc560aab.tar.bz2 |
gh-92619: Fix bug where the compiler duplicates exit blocks unnecessarily (GH-92620)
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c index 10d6307..45944ae 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -9280,7 +9280,15 @@ trim_unused_consts(struct compiler *c, struct assembler *a, PyObject *consts) static inline int is_exit_without_lineno(basicblock *b) { - return b->b_exit && b->b_instr[0].i_lineno < 0; + if (!b->b_exit) { + return 0; + } + for (int i = 0; i < b->b_iused; i++) { + if (b->b_instr[i].i_lineno >= 0) { + return 0; + } + } + return 1; } /* PEP 626 mandates that the f_lineno of a frame is correct |