mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
bpo-44622: Set line number of END_ASYNC_FOR to match that of iterator. (GH-27160) (GH-27163)
(cherry picked from commit f333ab0f2e)
This commit is contained in:
parent
2ce8af3cbc
commit
47695e3c88
2 changed files with 14 additions and 2 deletions
|
|
@ -906,10 +906,20 @@ def return_genexp():
|
|||
genexp_lines = [None, 1, 3, 1]
|
||||
|
||||
genexp_code = return_genexp.__code__.co_consts[1]
|
||||
code_lines = [None if line is None else line-return_genexp.__code__.co_firstlineno
|
||||
code_lines = [ None if line is None else line-return_genexp.__code__.co_firstlineno
|
||||
for (_, _, line) in genexp_code.co_lines() ]
|
||||
self.assertEqual(genexp_lines, code_lines)
|
||||
|
||||
def test_line_number_implicit_return_after_async_for(self):
|
||||
|
||||
async def test(aseq):
|
||||
async for i in aseq:
|
||||
body
|
||||
|
||||
expected_lines = [None, 1, 2, 1]
|
||||
code_lines = [ None if line is None else line-test.__code__.co_firstlineno
|
||||
for (_, _, line) in test.__code__.co_lines() ]
|
||||
self.assertEqual(expected_lines, code_lines)
|
||||
|
||||
def test_big_dict_literal(self):
|
||||
# The compiler has a flushing point in "compiler_dict" that calls compiles
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue