From: Amaury Forgeot d'Arc Date: Mon, 4 Feb 2008 23:51:55 +0000 (+0000) Subject: No need to emit co_lnotab item when both offsets are zeros. X-Git-Tag: v2.5.2c1~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc212104e48eaaf2038c0a3f9dc2e1304a039a8b;p=python No need to emit co_lnotab item when both offsets are zeros. r60579 broke a test test_compile, which seems to test an "implementation detail" IMO. Also test that this correction does not impact the debugger. --- diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index 64dca9fd0c..ab47431018 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -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 diff --git a/Python/compile.c b/Python/compile.c index 6df09dc53c..4dfc42d928 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -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;