gh-114083: apply optimization of LOAD_CONST instructions to the whole CFG before optimize_basic_block. (#114408)

This commit is contained in:
Irit Katriel 2024-01-22 17:12:06 +00:00 committed by GitHub
parent a53e56e7d8
commit ed30a3c337
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 192 additions and 144 deletions

View file

@ -449,9 +449,17 @@ class TestSpecifics(unittest.TestCase):
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("""