New submission from Martijn Pieters:
SyntaxError.__init__() checks for the `print` and `exec` error cases where the
user forgot to use parentheses:
>>> exec 1
File "<stdin>", line 1
exec 1
^
SyntaxError: Missing parentheses in call to 'exec'
>>> print 1
File "<stdin>", line 1
print 1
^
SyntaxError: Missing parentheses in call to 'print'
However, this check is also applied to *subclasses* of SyntaxError:
>>> if True:
... print "Look ma, no parens!"
File "<stdin>", line 2
print "Look ma, no parens!"
^
IndentationError: Missing parentheses in call to 'print'
and
>>> compile('if 1:\n 1\n\tprint "Look ma, tabs!"', '', 'single')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "", line 3
print "Look ma, tabs!"
^
TabError: Missing parentheses in call to 'print'
Perhaps the check needs to be limited to just the exact type.
----------
messages: 300002
nosy: mjpieters
priority: normal
severity: normal
status: open
title: Only check for print and exec parentheses cases for SyntaxError, not
subclasses
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue31161>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com