New submission from Jean-Paul Calderone <exar...@divmod.com>: Sometimes a syntax error in source passed to `compiler.parse´ causes a `SyntaxError´ with lots of nice information to be raised:
>>> from compiler import parse >>> try: ... parse("def f(") ... except SyntaxError, e: ... pass ... >>> e SyntaxError('unexpected EOF while parsing', (None, 1, 6, 'def f(')) But for other syntax errors, only a string message is provided, no location information: >>> try: ... parse("def f(x=10, y): pass") ... except SyntaxError, f: ... pass ... >>> f SyntaxError('non-default argument follows default argument',) >>> try: ... parse("f(x=10, y)") ... except SyntaxError, g: ... pass ... >>> g SyntaxError('non-keyword arg after keyword arg',) >>> On the other hand, the built in compiler produces exceptions which do have this information in these cases. The absence of the information makes the job of tools trying to operate on Python source code more difficult (naively written, they'll simply fail when they encounter one of these less informative exceptions). ---------- components: Library (Lib) messages: 80559 nosy: exarkun severity: normal status: open title: compiler.parse raises SyntaxErrors without line number information type: behavior _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5064> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com