Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-120367: fix removal of redundant NOPs and jumps after reordering hot-cold blocks#120425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
…ot-cold blocks
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -502,6 +502,31 @@ def test_compile_invalid_namedexpr(self): | ||
| with self.assertRaisesRegex(TypeError, "NamedExpr target must be a Name"): | ||
| compile(ast.fix_missing_locations(m), "<file>", "exec") | ||
| def test_compile_redundant_jumps_and_nops_after_moving_cold_blocks(self): | ||
| # See gh-120367 | ||
| code=textwrap.dedent(""" | ||
| try: | ||
| pass | ||
| except: | ||
| pass | ||
| else: | ||
| match name_2: | ||
| case b'': | ||
| pass | ||
| finally: | ||
| something | ||
| """) | ||
| tree = ast.parse(code) | ||
iritkatriel marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| for node in ast.walk(tree): | ||
| if hasattr(node,"lineno"): | ||
| del node.lineno | ||
| del node.end_lineno | ||
| del node.col_offset | ||
| del node.end_col_offset | ||
Comment on lines +524 to +528 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. why is it important for this test to remove node locations and then use | ||
| compile(ast.fix_missing_locations(tree), "<file>", "exec") | ||
| def test_compile_ast(self): | ||
| fname = __file__ | ||
| if fname.lower().endswith('pyc'): | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix crash in compiler on code with redundant NOPs and JUMPs which show up | ||
| after exception handlers are moved to the end of the code. |