New submission from Andre Roberge <[email protected]>:
Consider the following two examples with the latest beta release:
Python 3.10.0b3 ...
>>> def 3job(x):
File "<stdin>", line 1
def 3job(x):
^
SyntaxError: invalid imaginary literal
>>> def 3ob(x):
File "<stdin>", line 1
def 3ob(x):
^
SyntaxError: invalid decimal literal
In most situations, these error messages are fantastic improvements compared
with what was done previously. Here however, as they are intended to be used as
function names, perhaps they could be improved.
**If** it is easy to check if those "invalid number literals" are preceded by
"def" during the analysis, perhaps a better error message might be
SyntaxError: invalid function name
If such an analysis would be difficult to do, I would suggest to simply close
this issue as these examples are probably almost never going to be seen in
real-life situations.
(One might also consider to change the error message in the cases of "invalid
octal" and "invalid hexadecimal" when they are used as function names.)
----------
components: Parser
messages: 396027
nosy: aroberge, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Suggestion: change existing error message for invalid function name
versions: Python 3.10
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44448>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com