mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-100126: Skip incomplete frames in more places (GH-100613)
This commit is contained in:
parent
2e80c2a976
commit
61762b9387
12 changed files with 62 additions and 46 deletions
|
@ -1,4 +1,5 @@
|
|||
import gc
|
||||
import operator
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
|
@ -372,6 +373,26 @@ class TestIncompleteFrameAreInvisible(unittest.TestCase):
|
|||
)
|
||||
sneaky_frame_object = sneaky_frame_object.f_back
|
||||
|
||||
def test_entry_frames_are_invisible_during_teardown(self):
|
||||
class C:
|
||||
"""A weakref'able class."""
|
||||
|
||||
def f():
|
||||
"""Try to find globals and locals as this frame is being cleared."""
|
||||
ref = C()
|
||||
# Ignore the fact that exec(C()) is a nonsense callback. We're only
|
||||
# using exec here because it tries to access the current frame's
|
||||
# globals and locals. If it's trying to get those from a shim frame,
|
||||
# we'll crash before raising:
|
||||
return weakref.ref(ref, exec)
|
||||
|
||||
with support.catch_unraisable_exception() as catcher:
|
||||
# Call from C, so there is a shim frame directly above f:
|
||||
weak = operator.call(f) # BOOM!
|
||||
# Cool, we didn't crash. Check that the callback actually happened:
|
||||
self.assertIs(catcher.unraisable.exc_type, TypeError)
|
||||
self.assertIsNone(weak())
|
||||
|
||||
@unittest.skipIf(_testcapi is None, 'need _testcapi')
|
||||
class TestCAPI(unittest.TestCase):
|
||||
def getframe(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue