Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked frompython/cpython

Commit0695ff0

Browse files
iritkatrielmrahtz
authored andcommitted
pythongh-120367: fix bug where compiler detects redundant jump after pseudo op replacement (python#120714)
1 parent5d10626 commit0695ff0

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

‎Lib/test/test_compile.py‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,32 @@ def test_compile_redundant_jumps_and_nops_after_moving_cold_blocks(self):
519519

520520
tree=ast.parse(code)
521521

522-
# make all instructions locations the same to create redundancies
522+
# make all instruction locations the same to create redundancies
523+
fornodeinast.walk(tree):
524+
ifhasattr(node,"lineno"):
525+
delnode.lineno
526+
delnode.end_lineno
527+
delnode.col_offset
528+
delnode.end_col_offset
529+
530+
compile(ast.fix_missing_locations(tree),"<file>","exec")
531+
532+
deftest_compile_redundant_jump_after_convert_pseudo_ops(self):
533+
# See gh-120367
534+
code=textwrap.dedent("""
535+
if name_2:
536+
pass
537+
else:
538+
try:
539+
pass
540+
except:
541+
pass
542+
~name_5
543+
""")
544+
545+
tree=ast.parse(code)
546+
547+
# make all instruction locations the same to create redundancies
523548
fornodeinast.walk(tree):
524549
ifhasattr(node,"lineno"):
525550
delnode.lineno
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug where compiler creates a redundant jump during pseudo-op replacement. Can only happen with a synthetic AST that has a try on the same line as the instruction following the exception handler.

‎Python/flowgraph.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ convert_pseudo_ops(cfg_builder *g)
23892389
}
23902390
}
23912391
}
2392-
returnremove_redundant_nops(g);
2392+
returnremove_redundant_nops_and_jumps(g);
23932393
}
23942394

23952395
staticinlinebool

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp