]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-94814: Improve coverage of _PyCode_CreateLineArray (GH-94852)
authorMichael Droettboom <mdboom@gmail.com>
Fri, 15 Jul 2022 17:00:27 +0000 (13:00 -0400)
committerGitHub <noreply@github.com>
Fri, 15 Jul 2022 17:00:27 +0000 (10:00 -0700)
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
Lib/test/test_sys_settrace.py

index f03b03e19a2528b3ffc1472cd30d91c223fba1df..4f2dd4f9eade37e2fe0762c53aa9b820e304a8aa 100644 (file)
@@ -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',