diff options
author | Mark Shannon <mark@hotpy.org> | 2021-07-15 13:37:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-15 13:37:57 (GMT) |
commit | f333ab0f2edec26a769ed558263ac662e5475451 (patch) | |
tree | 9b9a6ea59e24e1d7c053d951e2983cdb297bfe69 /Lib/test/test_compile.py | |
parent | b83861f0265e07207a6ae2c49c40fa8f447893f2 (diff) | |
download | cpython-f333ab0f2edec26a769ed558263ac662e5475451.zip cpython-f333ab0f2edec26a769ed558263ac662e5475451.tar.gz cpython-f333ab0f2edec26a769ed558263ac662e5475451.tar.bz2 |
bpo-44622: Set line number of END_ASYNC_FOR to match that of iterator. (GH-27160)
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r-- | Lib/test/test_compile.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index c994741..29bfd71 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -943,10 +943,20 @@ if 1: 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 |