mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-99110: Initialize frame->previous
in init_frame to fix segmentation fault when accessing frame.f_back
(#100182)
This commit is contained in:
parent
2659036c75
commit
88d565f32a
5 changed files with 34 additions and 1 deletions
|
@ -408,6 +408,15 @@ class TestCAPI(unittest.TestCase):
|
|||
frame = next(gen)
|
||||
self.assertIs(gen, _testcapi.frame_getgenerator(frame))
|
||||
|
||||
def test_frame_fback_api(self):
|
||||
"""Test that accessing `f_back` does not cause a segmentation fault on
|
||||
a frame created with `PyFrame_New` (GH-99110)."""
|
||||
def dummy():
|
||||
pass
|
||||
|
||||
frame = _testcapi.frame_new(dummy.__code__, globals(), locals())
|
||||
# The following line should not cause a segmentation fault.
|
||||
self.assertIsNone(frame.f_back)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue