]> granicus.if.org Git - python/commitdiff
No need to emit co_lnotab item when both offsets are zeros.
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 4 Feb 2008 23:51:55 +0000 (23:51 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 4 Feb 2008 23:51:55 +0000 (23:51 +0000)
r60579 broke a test test_compile, which seems to test an "implementation detail" IMO.

Also test that this correction does not impact the debugger.

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

index 64dca9fd0cd9f3da90ab21cd8a084e845ed491bf..ab47431018f6340b55659bab2d3fb6f6d295084c 100644 (file)
@@ -352,6 +352,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 6df09dc53c08652cda353b646ad36db9e57ede65..4dfc42d92893147daa3cd3e2200548c994130494 100644 (file)
@@ -4191,6 +4191,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;