]> granicus.if.org Git - python/commitdiff
Change r60575 broke test_compile:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 5 Feb 2008 00:26:21 +0000 (00:26 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 5 Feb 2008 00:26:21 +0000 (00:26 +0000)
there is no need to emit co_lnotab item when both offsets are zeros.

Lib/test/test_trace.py
Python/compile.c

index 7f7db334ed06370dcd575e29b289c32b75823bb3..6ad38d103ad97980dd9f12ac2c8e3b73db7b2956 100644 (file)
@@ -366,6 +366,15 @@ class TraceTestCase(unittest.TestCase):
              (3, 'line'),
              (3, 'return')])
 
+    def test_16_blank_lines(self):
+        exec("def f():\n" + "\n" * 256 + "    pass")
+        self.run_and_compare(
+            f,
+            [(0, 'call'),
+             (257, 'line'),
+             (257, 'return')])
+
+
 class RaisingTraceFuncTestCase(unittest.TestCase):
     def trace(self, frame, event, arg):
         """A trace function that raises an exception in response to a
index f9b5ac4a523c03b642bc6344b74db2b9f44726af..83a8fc07cee2f77837d10a8c514cc014947e4c66 100644 (file)
@@ -3560,6 +3560,9 @@ assemble_lnotab(struct assembler *a, struct instr *i)
        assert(d_bytecode >= 0);
        assert(d_lineno >= 0);
 
+       if(d_bytecode == 0 && d_lineno == 0)
+               return 1;
+
        if (d_bytecode > 255) {
                int j, nbytes, ncodes = d_bytecode / 255;
                nbytes = a->a_lnotab_off + 2 * ncodes;