New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improper use of the keyword-only syntax makes the parser crash #45914
Comments
I found that the parser fails to handle correctly the (incorrect) case >>> def f(*, **kw):
... pass
...
python: Python/ast.c:652: handle_keywordonly_args: Assertion `kwonlyargs
!= ((void *)0)' failed.
[1] 7872 abort (core dumped) ./python |
Fixed in r59432 I've altered the assert(). It now checks if either kwonlyargs and |
Err... I think it should raise a SyntaxError in this case. |
Why do you want to forbid def f(*, **kw) ? It's useful and it also works in release builds of Python 3.0a2. It |
Amaury is right. "def f(*, **kw): pass" should raise a SyntaxError. The |
Well, TOOWTDI and the like... |
Ah, you and Amaury are right! But I don't like Amaury's error message:
It doesn't explain what's wrong. How about
|
Kirk McDonald has an even better error message for us: SyntaxError: Cannot specify keyword only arguments without named arguments |
Here is another error message from Thomas Wouters 'named arguments must |
Right. |
I'm fine with your patch. Can you commit it please? |
Committed revision 59443. |
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: