bpo-44616: Mark all clean up instructions at end of named exception block as artificial (GH-27109) (GH-27135)

(cherry picked from commit e5862f79c1)
This commit is contained in:
Mark Shannon 2021-07-14 11:43:56 +01:00 committed by GitHub
parent 7e1d6308a3
commit 794ff7d505
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 3 deletions

View file

@ -1077,6 +1077,29 @@ class TraceTestCase(unittest.TestCase):
(1, 'line'),
(1, 'return')])
def test_no_tracing_of_named_except_cleanup(self):
def func():
x = 0
try:
1/x
except ZeroDivisionError as error:
if x:
raise
return "done"
self.run_and_compare(func,
[(0, 'call'),
(1, 'line'),
(2, 'line'),
(3, 'line'),
(3, 'exception'),
(4, 'line'),
(5, 'line'),
(7, 'line'),
(7, 'return')])
class SkipLineEventsTraceTestCase(TraceTestCase):
"""Repeat the trace tests, but with per-line events skipped"""