mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
[3.14] GH-100964: Fix reference cycle in exhausted generator frames (GH-141112) (#142902)
GH-100964: Fix reference cycle in exhausted generator frames (GH-141112)
(cherry picked from commit 92243dc62c)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
This commit is contained in:
parent
25a94708e5
commit
7134b407dc
3 changed files with 14 additions and 1 deletions
|
|
@ -134,6 +134,18 @@ def gen():
|
|||
self.assertEqual(len(resurrected), 1)
|
||||
self.assertIsInstance(resurrected[0].gi_code, types.CodeType)
|
||||
|
||||
def test_exhausted_generator_frame_cycle(self):
|
||||
def g():
|
||||
yield
|
||||
|
||||
generator = g()
|
||||
frame = generator.gi_frame
|
||||
self.assertIsNone(frame.f_back)
|
||||
next(generator)
|
||||
self.assertIsNone(frame.f_back)
|
||||
next(generator, None)
|
||||
self.assertIsNone(frame.f_back)
|
||||
|
||||
|
||||
class GeneratorTest(unittest.TestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue