summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-02-05 00:26:21 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-02-05 00:26:21 (GMT)
commit99af7dbc07a8c7e52c081d2b9398ce61cf40215a (patch)
tree62182da9e7991631ecb892e54c079ff21d9429af
parent6fd03bb6070586a3b069c90cf3892ba7573d6bf5 (diff)
downloadcpython-99af7dbc07a8c7e52c081d2b9398ce61cf40215a.zip
cpython-99af7dbc07a8c7e52c081d2b9398ce61cf40215a.tar.gz
cpython-99af7dbc07a8c7e52c081d2b9398ce61cf40215a.tar.bz2
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
-rw-r--r--Lib/test/test_trace.py9
-rw-r--r--Python/compile.c3
2 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 7f7db33..6ad38d1 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -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
diff --git a/Python/compile.c b/Python/compile.c
index f9b5ac4..83a8fc0 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -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;