mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-104976: Ensure trailing dedent tokens are emitted as the previous tokenizer (#104980)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
parent
402ee5a68b
commit
46b52e6e2b
4 changed files with 34 additions and 15 deletions
|
@ -82,7 +82,7 @@ class TokenizeTest(TestCase):
|
|||
NAME 'False' (4, 11) (4, 16)
|
||||
COMMENT '# NEWLINE' (4, 17) (4, 26)
|
||||
NEWLINE '\\n' (4, 26) (4, 27)
|
||||
DEDENT '' (4, 27) (4, 27)
|
||||
DEDENT '' (5, 0) (5, 0)
|
||||
""")
|
||||
indent_error_file = b"""\
|
||||
def k(x):
|
||||
|
@ -755,8 +755,8 @@ def"', """\
|
|||
NEWLINE '\\n' (2, 5) (2, 6)
|
||||
INDENT ' \\t' (3, 0) (3, 9)
|
||||
NAME 'pass' (3, 9) (3, 13)
|
||||
DEDENT '' (3, 14) (3, 14)
|
||||
DEDENT '' (3, 14) (3, 14)
|
||||
DEDENT '' (4, 0) (4, 0)
|
||||
DEDENT '' (4, 0) (4, 0)
|
||||
""")
|
||||
|
||||
def test_non_ascii_identifiers(self):
|
||||
|
@ -968,7 +968,7 @@ async def foo():
|
|||
NUMBER '1' (2, 17) (2, 18)
|
||||
OP ':' (2, 18) (2, 19)
|
||||
NAME 'pass' (2, 20) (2, 24)
|
||||
DEDENT '' (2, 25) (2, 25)
|
||||
DEDENT '' (3, 0) (3, 0)
|
||||
""")
|
||||
|
||||
self.check_tokenize('''async def foo(async): await''', """\
|
||||
|
@ -1016,7 +1016,7 @@ def f():
|
|||
NAME 'await' (6, 2) (6, 7)
|
||||
OP '=' (6, 8) (6, 9)
|
||||
NUMBER '2' (6, 10) (6, 11)
|
||||
DEDENT '' (6, 12) (6, 12)
|
||||
DEDENT '' (7, 0) (7, 0)
|
||||
""")
|
||||
|
||||
self.check_tokenize('''\
|
||||
|
@ -1054,7 +1054,7 @@ async def f():
|
|||
NAME 'await' (6, 2) (6, 7)
|
||||
OP '=' (6, 8) (6, 9)
|
||||
NUMBER '2' (6, 10) (6, 11)
|
||||
DEDENT '' (6, 12) (6, 12)
|
||||
DEDENT '' (7, 0) (7, 0)
|
||||
""")
|
||||
|
||||
def test_newline_after_parenthesized_block_with_comment(self):
|
||||
|
@ -2680,7 +2680,8 @@ async def f():
|
|||
|
||||
valid = generate_source(MAXINDENT - 1)
|
||||
tokens = list(_generate_tokens_from_c_tokenizer(valid))
|
||||
self.assertEqual(tokens[-1].type, DEDENT)
|
||||
self.assertEqual(tokens[-2].type, DEDENT)
|
||||
self.assertEqual(tokens[-1].type, ENDMARKER)
|
||||
compile(valid, "<string>", "exec")
|
||||
|
||||
invalid = generate_source(MAXINDENT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue