[Python-checkins] r65764 - in python/branches/tlee-ast-optimize: Lib/test/test_compile.py Python/compile.c

thomas.lee python-checkins at python.org
Sun Aug 17 15:47:51 CEST 2008


Author: thomas.lee
Date: Sun Aug 17 15:47:51 2008
New Revision: 65764

Log:
Fixing test_compile.

Modified:
   python/branches/tlee-ast-optimize/Lib/test/test_compile.py
   python/branches/tlee-ast-optimize/Python/compile.c

Modified: python/branches/tlee-ast-optimize/Lib/test/test_compile.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_compile.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_compile.py	Sun Aug 17 15:47:51 2008
@@ -177,7 +177,7 @@
         s256 = "".join(["\n"] * 256 + ["spam"])
         co = compile(s256, 'fn', 'exec')
         self.assertEqual(co.co_firstlineno, 257)
-        self.assertEqual(co.co_lnotab, '')
+        self.assertEqual(co.co_lnotab, [])
 
     def test_literals_with_leading_zeroes(self):
         for arg in ["077787", "0xj", "0x.", "0e",  "090000000000000",

Modified: python/branches/tlee-ast-optimize/Python/compile.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/compile.c	(original)
+++ python/branches/tlee-ast-optimize/Python/compile.c	Sun Aug 17 15:47:51 2008
@@ -3589,6 +3589,10 @@
 	PyObject* line = NULL;
 	PyObject* entry = NULL;
 
+	/* if this is the first line of code in a block, create no lnotab entry */
+	if (a->a_lineno == i->i_lineno)
+		return 1;
+
 	addr = PyLong_FromLong(a->a_offset);
 	if (addr == NULL)
 		goto error;


More information about the Python-checkins mailing list