mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue 24226: Fix parsing of many sequential one-line 'def' statements.
This commit is contained in:
parent
a2c145c2f3
commit
8085b80c18
3 changed files with 51 additions and 8 deletions
|
@ -1289,6 +1289,17 @@ class TestTokenize(TestCase):
|
|||
|
||||
self.assertTrue(encoding_used, encoding)
|
||||
|
||||
def test_oneline_defs(self):
|
||||
buf = []
|
||||
for i in range(500):
|
||||
buf.append('def i{i}(): return {i}'.format(i=i))
|
||||
buf.append('OK')
|
||||
buf = '\n'.join(buf)
|
||||
|
||||
# Test that 500 consequent, one-line defs is OK
|
||||
toks = list(tokenize(BytesIO(buf.encode('utf-8')).readline))
|
||||
self.assertEqual(toks[-2].string, 'OK') # [-1] is always ENDMARKER
|
||||
|
||||
def assertExactTypeEqual(self, opstr, *optypes):
|
||||
tokens = list(tokenize(BytesIO(opstr.encode('utf-8')).readline))
|
||||
num_optypes = len(optypes)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue