diff options
author | Mark Shannon <mark@hotpy.org> | 2022-01-20 11:46:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 11:46:39 +0000 |
commit | b04dfbbe4bd7071d46c8688c2263726ea31d33cd (patch) | |
tree | 17989daaffa384df343b53289845fba667e20acc /Lib/test | |
parent | d05a66339b5e07d72d96e4c30a34cc3821bb61a2 (diff) | |
download | cpython-git-b04dfbbe4bd7071d46c8688c2263726ea31d33cd.tar.gz |
bpo-46409: Make generators in bytecode (GH-30633)
* Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes.
* Trim frame and generator by word each.
* Minor refactor of frame.c
* Update test.test_sys to account for smaller frames.
* Treat generator functions as normal functions when evaluating and specializing.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_compile.py | 4 | ||||
-rw-r--r-- | Lib/test/test_generators.py | 2 | ||||
-rw-r--r-- | Lib/test/test_sys.py | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index e237156c75..f007aec9d3 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -954,7 +954,7 @@ if 1: x in y) - genexp_lines = [None, 1, 3, 1] + genexp_lines = [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 @@ -967,7 +967,7 @@ if 1: async for i in aseq: body - expected_lines = [None, 0, 1, 2, 1] + expected_lines = [0, 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) diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 4f4fd9c5aa..87a7dd69d1 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -897,7 +897,7 @@ From the Iterators list, about the types of these things. >>> type(i) <class 'generator'> >>> [s for s in dir(i) if not s.startswith('_')] -['close', 'gi_code', 'gi_frame', 'gi_running', 'gi_yieldfrom', 'send', 'throw'] +['close', 'gi_code', 'gi_frame', 'gi_running', 'gi_suspended', 'gi_yieldfrom', 'send', 'throw'] >>> from test.support import HAVE_DOCSTRINGS >>> print(i.__next__.__doc__ if HAVE_DOCSTRINGS else 'Implement next(self).') Implement next(self). diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 2c8c6ab6ce..accd35e4ab 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1386,7 +1386,7 @@ class SizeofTest(unittest.TestCase): def func(): return sys._getframe() x = func() - check(x, size('3Pi3c8P2ic?P')) + check(x, size('3Pi3c7P2ic??P')) # function def func(): pass check(func, size('14Pi')) @@ -1403,7 +1403,7 @@ class SizeofTest(unittest.TestCase): check(bar, size('PP')) # generator def get_gen(): yield 1 - check(get_gen(), size('P2P4P4c8P2ic?P')) + check(get_gen(), size('P2P4P4c7P2ic??P')) # iterator check(iter('abc'), size('lP')) # callable-iterator |