mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[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:
parent
8fe0b1d8fa
commit
68f5fa6683
7 changed files with 87 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue