Skip to content

Commit 582ae86

Browse files
authored
gh-94814: Improve coverage of _PyCode_CreateLineArray (GH-94852)
The case where there are more than (1 << 15) lines was not covered. I don't know if increasing test coverage requires a blurb -- let me know if it does. Automerge-Triggered-By: GH:brandtbucher
1 parent 944ff8c commit 582ae86

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Lib/test/test_sys_settrace.py

+22
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,28 @@ def func():
15711571

15721572
self.run_and_compare(func, EXPECTED_EVENTS)
15731573

1574+
def test_very_large_function(self):
1575+
# There is a separate code path when the number of lines > (1 << 15).
1576+
d = {}
1577+
exec("""def f(): # line 0
1578+
x = 0 # line 1
1579+
y = 1 # line 2
1580+
%s # lines 3 through (1 << 16)
1581+
x += 1 #
1582+
return""" % ('\n' * (1 << 16),), d)
1583+
f = d['f']
1584+
1585+
EXPECTED_EVENTS = [
1586+
(0, 'call'),
1587+
(1, 'line'),
1588+
(2, 'line'),
1589+
(65540, 'line'),
1590+
(65541, 'line'),
1591+
(65541, 'return'),
1592+
]
1593+
1594+
self.run_and_compare(f, EXPECTED_EVENTS)
1595+
15741596

15751597
EVENT_NAMES = [
15761598
'call',

0 commit comments

Comments
 (0)