Skip to content

Commit 1c6af67

Browse files
committed
pythongh-94814: Improve coverage of _PyCode_CreateLineArray
The case where there are more than (1 << 15) lines was not covered
1 parent 8d7089f commit 1c6af67

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Lib/test/test_sys_settrace.py

+25
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,31 @@ 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+
''' # line 3
1581+
%s # lines 4 through (1 << 16)
1582+
''' #
1583+
x += 1 #
1584+
return""" % ('\n' * (1 << 16),), d)
1585+
f = d['f']
1586+
1587+
EXPECTED_EVENTS = [
1588+
(0, 'call'),
1589+
(1, 'line'),
1590+
(2, 'line'),
1591+
(3, 'line'),
1592+
(65542, 'line'),
1593+
(65543, 'line'),
1594+
(65543, 'return'),
1595+
]
1596+
1597+
self.run_and_compare(f, EXPECTED_EVENTS)
1598+
15741599

15751600
EVENT_NAMES = [
15761601
'call',

0 commit comments

Comments
 (0)