[issue1634034] Show "expected" token on syntax error

Raymond Hettinger report at bugs.python.org
Wed Aug 11 21:51:44 CEST 2010


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

+1 on the basic idea to make error messages more informative where possible, but am not sure how it would work in any but the more simple cases.  

How would work in cases where there are multiple possible "expected" tokens?

   >>> def f(x 3):	
   SyntaxError: invalid syntax

It chokes at the "3".  The expected token is either a comma, colon, or closing parenthesis.

Also, the most annoying and least obvious syntax errors are ones that are revealed many characters away from the original cause (i.e. unbalanced opening brackets or parentheses).  Am not sure how you can readily construct a helpful message in these cases.

----------
nosy: +rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1634034>
_______________________________________


More information about the Python-bugs-list mailing list