You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2021-11-05.13:57:15.486>created_at=<Date2021-11-04.17:45:48.986>labels= ['interpreter-core']
title='Confusing parsing error message when trying to use True as keyword argument'updated_at=<Date2021-11-16.22:31:49.761>user='https://github.com/cfbolz'
A bit of a nitpick, but the following SyntaxError message is a bit confusing:
>>> f(True=1)
File "<stdin>", line 1
f(True=1)
^^^^^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
The problem with that line is not that it contains an assignment, it's almost a valid keyword argument after all. The problem is that the name of the keyword is True, which is no longer a name you can assign to. It would be better to produce the same error as with __debug__:
>>> f(__debug__=1)
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
The latter error message is however produced by the compiler, not the parser I think?
New changeset e2d6563 by Pablo Galindo Salgado in branch 'main': bpo-45716: Improve the error message when using True/False/None as keywords in a call (GH-29413) e2d6563
New changeset 5618c81 by Pablo Galindo Salgado in branch '3.10':
[3.10] bpo-45716: Improve the error message when using True/False/None as keywords in a call (GH-29413). (GH-29428) 5618c81
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: