summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_generators.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_generators.py')
-rw-r--r--Lib/test/test_generators.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 87a7dd6..e5aa7da 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -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