Skip to content

Commit

Permalink
pythongh-94814: Improve coverage of _PyCode_CreateLineArray (pythonGH…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
mdboom committed Jul 15, 2022
1 parent 944ff8c commit 582ae86
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Lib/test/test_sys_settrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,28 @@ 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
%s # lines 3 through (1 << 16)
x += 1 #
return""" % ('\n' * (1 << 16),), d)
f = d['f']

EXPECTED_EVENTS = [
(0, 'call'),
(1, 'line'),
(2, 'line'),
(65540, 'line'),
(65541, 'line'),
(65541, 'return'),
]

self.run_and_compare(f, EXPECTED_EVENTS)


EVENT_NAMES = [
'call',
Expand Down

0 comments on commit 582ae86

Please sign in to comment.