mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-45709: Fix tracing when exception is handled. (GH-29638)
This commit is contained in:
parent
29e5874d5a
commit
337cb480e9
3 changed files with 35 additions and 4 deletions
|
@ -1137,6 +1137,38 @@ class TraceTestCase(unittest.TestCase):
|
|||
(7, 'line'),
|
||||
(7, 'return')])
|
||||
|
||||
def test_tracing_exception_raised_in_with(self):
|
||||
|
||||
class NullCtx:
|
||||
def __enter__(self):
|
||||
return self
|
||||
def __exit__(self, *excinfo):
|
||||
pass
|
||||
|
||||
def func():
|
||||
try:
|
||||
with NullCtx():
|
||||
1/0
|
||||
except ZeroDivisionError:
|
||||
pass
|
||||
|
||||
self.run_and_compare(func,
|
||||
[(0, 'call'),
|
||||
(1, 'line'),
|
||||
(2, 'line'),
|
||||
(-5, 'call'),
|
||||
(-4, 'line'),
|
||||
(-4, 'return'),
|
||||
(3, 'line'),
|
||||
(3, 'exception'),
|
||||
(2, 'line'),
|
||||
(-3, 'call'),
|
||||
(-2, 'line'),
|
||||
(-2, 'return'),
|
||||
(4, 'line'),
|
||||
(5, 'line'),
|
||||
(5, 'return')])
|
||||
|
||||
|
||||
class SkipLineEventsTraceTestCase(TraceTestCase):
|
||||
"""Repeat the trace tests, but with per-line events skipped"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue