gh-113603: Compiler no longer tries to maintain the no-empty-block invariant (#113636)

This commit is contained in:
Irit Katriel 2024-01-03 16:57:48 +00:00 committed by GitHub
parent 0c3455a969
commit 7d01fb4808
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 78 deletions

View file

@ -448,6 +448,19 @@ class TestSpecifics(unittest.TestCase):
# See gh-113054
compile('if (5 if 5 else T): 0', '<eval>', 'exec')
def test_condition_expression_with_redundant_comparisons_compiles(self):
# See gh-113054
compile('if 9<9<9and 9or 9:9', '<eval>', 'exec')
def test_dead_code_with_except_handler_compiles(self):
compile(textwrap.dedent("""
if None:
with CM:
x = 1
else:
x = 2
"""), '<eval>', 'exec')
def test_compile_invalid_namedexpr(self):
# gh-109351
m = ast.Module(