Skip to content

Commit

Permalink
gh-94814: Improve coverage of _PyCode_CreateLineArray (GH-94852)
Browse files Browse the repository at this point in the history
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
(cherry picked from commit 582ae86)

Co-authored-by: Michael Droettboom <[email protected]>
  • Loading branch information
miss-islington and mdboom authored Jul 15, 2022
1 parent d9107aa commit 8f92ebb
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 8f92ebb

Please sign in to comment.