[Python-checkins] r65724 - in python/trunk: Lib/test/test_syntax.py Python/symtable.c

benjamin.peterson python-checkins at python.org
Sun Aug 17 00:11:34 CEST 2008


Author: benjamin.peterson
Date: Sun Aug 17 00:11:33 2008
New Revision: 65724

Log:
include filename and line number in SyntaxError


Modified:
   python/trunk/Lib/test/test_syntax.py
   python/trunk/Python/symtable.c

Modified: python/trunk/Lib/test/test_syntax.py
==============================================================================
--- python/trunk/Lib/test/test_syntax.py	(original)
+++ python/trunk/Lib/test/test_syntax.py	Sun Aug 17 00:11:33 2008
@@ -5,7 +5,7 @@
 >>> def f(x):
 ...     global x
 Traceback (most recent call last):
-SyntaxError: name 'x' is local and global
+SyntaxError: name 'x' is local and global (<doctest test.test_syntax[0]>, line 1)
 
 The tests are all raise SyntaxErrors.  They were created by checking
 each C call that raises SyntaxError.  There are several modules that

Modified: python/trunk/Python/symtable.c
==============================================================================
--- python/trunk/Python/symtable.c	(original)
+++ python/trunk/Python/symtable.c	Sun Aug 17 00:11:33 2008
@@ -373,6 +373,9 @@
 			PyErr_Format(PyExc_SyntaxError,
 				     "name '%s' is local and global",
 				     PyString_AS_STRING(name));
+			PyErr_SyntaxLocation(ste->ste_table->st_filename,
+					     ste->ste_lineno);
+			
 			return 0;
 		}
 		SET_SCOPE(dict, name, GLOBAL_EXPLICIT);


More information about the Python-checkins mailing list