mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
GH-107724: Fix the signature of PY_THROW
callback functions. (GH-107725)
This commit is contained in:
parent
2fb484e625
commit
52fbcf61b5
6 changed files with 39 additions and 18 deletions
|
@ -743,6 +743,13 @@ class ExceptionHandledRecorder(ExceptionRecorder):
|
|||
def __call__(self, code, offset, exc):
|
||||
self.events.append(("handled", type(exc)))
|
||||
|
||||
class ThrowRecorder(ExceptionRecorder):
|
||||
|
||||
event_type = E.PY_THROW
|
||||
|
||||
def __call__(self, code, offset, exc):
|
||||
self.events.append(("throw", type(exc)))
|
||||
|
||||
class ExceptionMonitoringTest(CheckEvents):
|
||||
|
||||
|
||||
|
@ -888,6 +895,31 @@ class ExceptionMonitoringTest(CheckEvents):
|
|||
func,
|
||||
recorders = self.exception_recorders)
|
||||
|
||||
def test_throw(self):
|
||||
|
||||
def gen():
|
||||
yield 1
|
||||
yield 2
|
||||
|
||||
def func():
|
||||
try:
|
||||
g = gen()
|
||||
next(g)
|
||||
g.throw(IndexError)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
self.check_balanced(
|
||||
func,
|
||||
recorders = self.exception_recorders)
|
||||
|
||||
events = self.get_events(
|
||||
func,
|
||||
TEST_TOOL,
|
||||
self.exception_recorders + (ThrowRecorder,)
|
||||
)
|
||||
self.assertEqual(events[0], ("throw", IndexError))
|
||||
|
||||
class LineRecorder:
|
||||
|
||||
event_type = E.LINE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue