diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-07-04 18:43:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-04 18:43:12 (GMT) |
commit | 68f5fa668343341b79ce1e23f1d9e773b98fd312 (patch) | |
tree | bc9b4ab897d1addc94ebf52c643e720fb75944d7 /Lib/test/test_generators.py | |
parent | 8fe0b1d8fa3451e923d7632263be6145a0734468 (diff) | |
download | cpython-68f5fa668343341b79ce1e23f1d9e773b98fd312.zip cpython-68f5fa668343341b79ce1e23f1d9e773b98fd312.tar.gz cpython-68f5fa668343341b79ce1e23f1d9e773b98fd312.tar.bz2 |
[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>
Diffstat (limited to 'Lib/test/test_generators.py')
-rw-r--r-- | Lib/test/test_generators.py | 37 |
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 |