[issue21669] Custom error messages when print & exec are used as statements
Nick Coghlan
report at bugs.python.org
Sat Jun 7 14:37:07 CEST 2014
Nick Coghlan added the comment:
Updated patch with the heuristics factored out into a helper function, with a more detailed explanation and additional logic to handle compound statements.
>>> def foo():
... print bar
File "<stdin>", line 2
print bar
^
SyntaxError: Missing parentheses in call to 'print'
It's still just basic string hackery, though. The one liner handling, for example, relies on the fact that ":<whitespace>print " and ":<whitespace>exec " are going to be uncommon outside Python 2 code being ported to Python 3, so it just looks for the first colon on the line and checks from there, without worrying about slice notation or dicts.
----------
Added file: http://bugs.python.org/file35510/issue21669_custom_error_messages_v2.diff
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21669>
_______________________________________
More information about the Python-bugs-list
mailing list