[3.11] GH-103971: Fix incorrect locations for code following case blocks

This commit is contained in:
Tian Gao 2023-04-28 13:08:25 -07:00 committed by GitHub
parent 4219074127
commit fee3c91a19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View file

@ -3151,6 +3151,19 @@ class TestTracing(unittest.TestCase):
self.assertListEqual(self._trace(f, "go x"), [1, 2, 3])
self.assertListEqual(self._trace(f, "spam"), [1, 2, 3])
def test_unreachable_code(self):
def f(command): # 0
match command: # 1
case 1: # 2
if False: # 3
return 1 # 4
case _: # 5
if False: # 6
return 0 # 7
self.assertListEqual(self._trace(f, 1), [1, 2, 3])
self.assertListEqual(self._trace(f, 0), [1, 2, 5, 6])
def test_parser_deeply_nested_patterns(self):
# Deeply nested patterns can cause exponential backtracking when parsing.
# See gh-93671 for more information.