mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140373: Correctly emit PY_UNWIND event when generator is closed (GH-140767)
This commit is contained in:
parent
ac1ffd7785
commit
d17f28fed5
6 changed files with 30 additions and 1 deletions
|
|
@ -1079,6 +1079,25 @@ def f():
|
|||
|
||||
self.assertEqual(events, expected)
|
||||
|
||||
# gh-140373
|
||||
def test_gen_unwind(self):
|
||||
def gen():
|
||||
yield 1
|
||||
|
||||
def f():
|
||||
g = gen()
|
||||
next(g)
|
||||
g.close()
|
||||
|
||||
recorders = (
|
||||
UnwindRecorder,
|
||||
)
|
||||
events = self.get_events(f, TEST_TOOL, recorders)
|
||||
expected = [
|
||||
("unwind", GeneratorExit, "gen"),
|
||||
]
|
||||
self.assertEqual(events, expected)
|
||||
|
||||
class LineRecorder:
|
||||
|
||||
event_type = E.LINE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue