Skip to content

Commit

Permalink
pythongh-94814: Improve coverage of _PyCode_CreateLineArray
Browse files Browse the repository at this point in the history
The case where there are more than (1 << 15) lines was not covered
  • Loading branch information
mdboom committed Jul 14, 2022
1 parent 8d7089f commit 1c6af67
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Lib/test/test_sys_settrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,31 @@ def func():

self.run_and_compare(func, EXPECTED_EVENTS)

def test_very_large_function(self):
# There is a separate code path when the number of lines > (1 << 15).
d = {}
exec("""def f(): # line 0
x = 0 # line 1
y = 1 # line 2
''' # line 3
%s # lines 4 through (1 << 16)
''' #
x += 1 #
return""" % ('\n' * (1 << 16),), d)
f = d['f']

EXPECTED_EVENTS = [
(0, 'call'),
(1, 'line'),
(2, 'line'),
(3, 'line'),
(65542, 'line'),
(65543, 'line'),
(65543, 'return'),
]

self.run_and_compare(f, EXPECTED_EVENTS)


EVENT_NAMES = [
'call',
Expand Down

0 comments on commit 1c6af67

Please sign in to comment.