summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-05-10 21:01:17 (GMT)
committerGitHub <noreply@github.com>2022-05-10 21:01:17 (GMT)
commit6a17cdebe9d3571d0c02645880f53a05e9ff7fda (patch)
treea693ed8a9bfeb2204a6102ba684ea456cc2dc253 /Python
parent6546af31ee8d36d6d240f3ce434fbd13a2d7e53b (diff)
downloadcpython-6a17cdebe9d3571d0c02645880f53a05e9ff7fda.zip
cpython-6a17cdebe9d3571d0c02645880f53a05e9ff7fda.tar.gz
cpython-6a17cdebe9d3571d0c02645880f53a05e9ff7fda.tar.bz2
gh-92619: Fix bug where the compiler duplicates exit blocks unnecessarily (GH-92620) (GH-92621)
(cherry picked from commit 7c6b7ade8df35355484d3944779fe35dcc560aab) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c10
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