bpo-42246: Don't eliminate jumps to jumps, if it will break PEP 626. (GH-23896)

This commit is contained in:
Mark Shannon 2020-12-23 11:43:10 +00:00 committed by GitHub
parent d90ff37681
commit 28b75c80dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 4355 additions and 4253 deletions

View file

@ -810,6 +810,70 @@ class TraceTestCase(unittest.TestCase):
(6, 'line'),
(6, 'return')])
def test_break_to_continue1(self):
def func():
TRUE = 1
x = [1]
while x:
x.pop()
while TRUE:
break
continue
self.run_and_compare(func,
[(0, 'call'),
(1, 'line'),
(2, 'line'),
(3, 'line'),
(4, 'line'),
(5, 'line'),
(6, 'line'),
(7, 'line'),
(3, 'line'),
(3, 'return')])
def test_break_to_continue2(self):
def func():
TRUE = 1
x = [1]
while x:
x.pop()
while TRUE:
break
else:
continue
self.run_and_compare(func,
[(0, 'call'),
(1, 'line'),
(2, 'line'),
(3, 'line'),
(4, 'line'),
(5, 'line'),
(6, 'line'),
(3, 'line'),
(3, 'return')])
def test_break_to_break(self):
def func():
TRUE = 1
while TRUE:
while TRUE:
break
break
self.run_and_compare(func,
[(0, 'call'),
(1, 'line'),
(2, 'line'),
(3, 'line'),
(4, 'line'),
(5, 'line'),
(5, 'return')])
class SkipLineEventsTraceTestCase(TraceTestCase):
"""Repeat the trace tests, but with per-line events skipped"""