Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,17 @@ def test_condition_expression_with_dead_blocks_compiles(self):
compile('if (5 if 5 else T): 0', '<eval>', 'exec')

def test_condition_expression_with_redundant_comparisons_compiles(self):
# See gh-113054
with self.assertWarns(SyntaxWarning):
compile('if 9<9<9and 9or 9:9', '<eval>', 'exec')
# See gh-113054, gh-114083
exprs = [
'if 9<9<9and 9or 9:9',
'if 9<9<9and 9or 9or 9:9',
'if 9<9<9and 9or 9or 9or 9:9',
'if 9<9<9and 9or 9or 9or 9or 9:9',
]
for expr in exprs:
with self.subTest(expr=expr):
with self.assertWarns(SyntaxWarning):
compile(expr, '<eval>', 'exec')

def test_dead_code_with_except_handler_compiles(self):
compile(textwrap.dedent("""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compiler applies folding of LOAD_CONST with following instruction in a separate pass before other optimisations. This enables jump threading in certain circumstances.
Loading