[Python-ideas] Reporting unmatched parentheses in SyntaxError messages?
Nick Coghlan
ncoghlan at gmail.com
Wed Jul 8 07:53:44 CEST 2015
One of the more opaque error messages new Python users can encounter
is a syntax error due to unmatched parentheses:
File "/home/me/myfile.py", line 11
data = func()
^
SyntaxError: invalid syntax
While I have no idea how we could implement it, I'm wondering if that
might be clearer if the error message instead looked more like this:
File "/home/me/myfile.py", line 11
data = func()
^
SyntaxError: invalid syntax (Unmatched '(' on line 10)
Or, similarly,
SyntaxError: invalid syntax (Unmatched '[' on line 10)
SyntaxError: invalid syntax (Unmatched '{' on line 10)
I'm not sure it would be feasible though - we generate syntax errors
from a range of locations where we don't have access to the original
token data any more :(
Regards,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list