This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author exarkun
Recipients exarkun
Date 2009-01-26.03:25:42
SpamBayes Score 2.5635576e-05
Marked as misclassified No
Message-id <1232940344.37.0.615917855536.issue5064@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2009-01-26 03:25:44exarkunsetrecipients: + exarkun
2009-01-26 03:25:44exarkunsetmessageid: <1232940344.37.0.615917855536.issue5064@psf.upfronthosting.co.za>
2009-01-26 03:25:43exarkunlinkissue5064 messages
2009-01-26 03:25:42exarkuncreate