[3.11] GH-97752: Clear the previous member of newly-created generator/coroutine frames (GH-97812)

(cherry picked from commit 93fcc1f413)
This commit is contained in:
Miss Islington (bot) 2022-10-03 21:03:26 -07:00 committed by Pablo Galindo
parent 4e0fda59f1
commit 585c95df95
No known key found for this signature in database
GPG key ID: FFE87404168BD847
3 changed files with 24 additions and 0 deletions

View file

@ -206,6 +206,25 @@ class GeneratorTest(unittest.TestCase):
finally:
gc.set_threshold(*thresholds)
def test_ag_frame_f_back(self):
async def f():
yield
ag = f()
self.assertIsNone(ag.ag_frame.f_back)
def test_cr_frame_f_back(self):
async def f():
pass
cr = f()
self.assertIsNone(cr.cr_frame.f_back)
cr.close() # Suppress RuntimeWarning.
def test_gi_frame_f_back(self):
def f():
yield
gi = f()
self.assertIsNone(gi.gi_frame.f_back)
class ExceptionTest(unittest.TestCase):