From: <fwi...@us...> - 2009-01-09 15:16:25
|
Revision: 5900 http://jython.svn.sourceforge.net/jython/?rev=5900&view=rev Author: fwierzbicki Date: 2009-01-09 15:16:08 +0000 (Fri, 09 Jan 2009) Log Message: ----------- Fix for wrong error line number when file ends with open paren. Modified Paths: -------------- trunk/jython/Lib/test/test_eof_jy.py trunk/jython/src/org/python/antlr/PythonTokenSource.java Added Paths: ----------- trunk/jython/Lib/test/eof_fodder7.py Added: trunk/jython/Lib/test/eof_fodder7.py =================================================================== --- trunk/jython/Lib/test/eof_fodder7.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder7.py 2009-01-09 15:16:08 UTC (rev 5900) @@ -0,0 +1,5 @@ +def hi(): + pass + +def bye(): + hi( Modified: trunk/jython/Lib/test/test_eof_jy.py =================================================================== --- trunk/jython/Lib/test/test_eof_jy.py 2009-01-09 04:50:22 UTC (rev 5899) +++ trunk/jython/Lib/test/test_eof_jy.py 2009-01-09 15:16:08 UTC (rev 5900) @@ -45,6 +45,12 @@ except ImportError, cause: self.fail(cause) + def test_trailing_paren(self): + try: + import eof_fodder7 + except SyntaxError, cause: + self.assertEquals(cause.lineno, 5) + #============================================================================== def test_main(verbose=None): Modified: trunk/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTokenSource.java 2009-01-09 04:50:22 UTC (rev 5899) +++ trunk/jython/src/org/python/antlr/PythonTokenSource.java 2009-01-09 15:16:08 UTC (rev 5900) @@ -146,6 +146,7 @@ } private void generateNewline(Token t) { + //System.out.println("generating newline from token: " + t); CommonToken newline = new CommonToken(PythonLexer.NEWLINE, "\n"); newline.setLine(t.getLine()); newline.setCharPositionInLine(t.getCharPositionInLine()); @@ -153,9 +154,12 @@ } private void handleEOF(CommonToken eof, CommonToken prev) { + //System.out.println("processing eof with token: " + prev); if (prev != null) { eof.setStartIndex(prev.getStopIndex()); eof.setStopIndex(prev.getStopIndex()); + eof.setLine(prev.getLine()); + eof.setCharPositionInLine(prev.getCharPositionInLine()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |