[3.11] GH-94262: Don't create frame objects for frames that aren't yet complete. (GH-94371) (#94482)

Co-authored-by: Mark Shannon <mark@hotpy.org>
This commit is contained in:
Miss Islington (bot) 2022-07-04 11:43:12 -07:00 committed by GitHub
parent 8fe0b1d8fa
commit 68f5fa6683
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 87 additions and 13 deletions

View file

@ -170,6 +170,43 @@ class GeneratorTest(unittest.TestCase):
g.send(0)
self.assertEqual(next(g), 1)
def test_handle_frame_object_in_creation(self):
#Attempt to expose partially constructed frames
#See https://github.com/python/cpython/issues/94262
def cb(*args):
inspect.stack()
def gen():
yield 1
thresholds = gc.get_threshold()
gc.callbacks.append(cb)
gc.set_threshold(1, 0, 0)
try:
gen()
finally:
gc.set_threshold(*thresholds)
gc.callbacks.pop()
class Sneaky:
def __del__(self):
inspect.stack()
sneaky = Sneaky()
sneaky._s = Sneaky()
sneaky._s._s = sneaky
gc.set_threshold(1, 0, 0)
try:
del sneaky
gen()
finally:
gc.set_threshold(*thresholds)
class ExceptionTest(unittest.TestCase):
# Tests for the issue #23353: check that the currently handled exception