summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMichael Droettboom <mdboom@gmail.com>2022-07-15 17:00:27 (GMT)
committerGitHub <noreply@github.com>2022-07-15 17:00:27 (GMT)
commit582ae86b3f07d806f145b3eb9009efd9fbf2e041 (patch)
treec018c430d84b4fff867c0d2ed4d864b557b815a5 /Lib
parent944ff8c57c9e8ff5a5bd18925070ddb1504490ab (diff)
downloadcpython-582ae86b3f07d806f145b3eb9009efd9fbf2e041.zip
cpython-582ae86b3f07d806f145b3eb9009efd9fbf2e041.tar.gz
cpython-582ae86b3f07d806f145b3eb9009efd9fbf2e041.tar.bz2
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
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_sys_settrace.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index f03b03e..4f2dd4f 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -1571,6 +1571,28 @@ class TraceTestCase(unittest.TestCase):
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',