This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2007年12月08日 18:13 by alexandre.vassalotti, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| kwonly.patch | amaury.forgeotdarc, 2007年12月08日 22:29 | |||
| kwonly2.patch | amaury.forgeotdarc, 2007年12月08日 23:50 | |||
| Messages (12) | |||
|---|---|---|---|
| msg58299 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) | Date: 2007年12月08日 18:13 | |
I found that the parser fails to handle correctly the (incorrect) case where the single-star (*), used for delimiting keyword-only arguments, is immediately followed by a **keywords parameter: >>> def f(*, **kw): ... pass ... python: Python/ast.c:652: handle_keywordonly_args: Assertion `kwonlyargs != ((void *)0)' failed. [1] 7872 abort (core dumped) ./python |
|||
| msg58300 - (view) | Author: Christian Heimes (christian.heimes) * (Python committer) | Date: 2007年12月08日 22:12 | |
Fixed in r59432 I've altered the assert(). It now checks if either kwonlyargs and kwdefault or both not NULL or the next node is a DOUBLESTAR. |
|||
| msg58301 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2007年12月08日 22:29 | |
Err... I think it should raise a SyntaxError in this case. See my attached patch. |
|||
| msg58302 - (view) | Author: Christian Heimes (christian.heimes) * (Python committer) | Date: 2007年12月08日 22:45 | |
Why do you want to forbid def f(*, **kw) ? It's useful and it also works in release builds of Python 3.0a2. It only breaks in debug builds because the assert() gets triggered. |
|||
| msg58303 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) | Date: 2007年12月08日 22:59 | |
Amaury is right. "def f(*, **kw): pass" should raise a SyntaxError. The keyword-only delimiter is useless since the **kw parameter already only accepts keywords. |
|||
| msg58304 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2007年12月08日 23:01 | |
> Why do you want to forbid > def f(*, **kw) Well, TOOWTDI and the like... and the first time I saw it, it seemed that any number of parameters is allowed! |
|||
| msg58306 - (view) | Author: Christian Heimes (christian.heimes) * (Python committer) | Date: 2007年12月08日 23:10 | |
Ah, you and Amaury are right! But I don't like Amaury's error message: SyntaxError: no name for vararg It doesn't explain what's wrong. How about SyntaxError: keyword only arguments require at least one keyword |
|||
| msg58308 - (view) | Author: Christian Heimes (christian.heimes) * (Python committer) | Date: 2007年12月08日 23:18 | |
Kirk McDonald has an even better error message for us: SyntaxError: Cannot specify keyword only arguments without named arguments |
|||
| msg58309 - (view) | Author: Christian Heimes (christian.heimes) * (Python committer) | Date: 2007年12月08日 23:27 | |
Here is another error message from Thomas Wouters 'named arguments must follow bare *' |
|||
| msg58310 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2007年12月08日 23:50 | |
Right. We should also replace the other occurence of "no name for vararg". Here is another patch, against the current revision (59434). |
|||
| msg58319 - (view) | Author: Christian Heimes (christian.heimes) * (Python committer) | Date: 2007年12月09日 15:52 | |
I'm fine with your patch. Can you commit it please? |
|||
| msg58330 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2007年12月09日 21:50 | |
Committed revision 59443. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:28 | admin | set | github: 45914 |
| 2008年01月06日 22:29:44 | admin | set | keywords:
- py3k versions: Python 3.0 |
| 2007年12月09日 21:50:46 | amaury.forgeotdarc | set | status: open -> closed messages: + msg58330 |
| 2007年12月09日 15:52:23 | christian.heimes | set | messages: + msg58319 |
| 2007年12月08日 23:50:53 | amaury.forgeotdarc | set | files:
+ kwonly2.patch messages: + msg58310 |
| 2007年12月08日 23:27:25 | christian.heimes | set | messages: + msg58309 |
| 2007年12月08日 23:18:38 | christian.heimes | set | messages: + msg58308 |
| 2007年12月08日 23:10:37 | christian.heimes | set | messages: + msg58306 |
| 2007年12月08日 23:01:45 | amaury.forgeotdarc | set | messages: + msg58304 |
| 2007年12月08日 22:59:58 | alexandre.vassalotti | set | messages: + msg58303 |
| 2007年12月08日 22:45:39 | christian.heimes | set | messages: + msg58302 |
| 2007年12月08日 22:38:13 | amaury.forgeotdarc | set | status: closed -> open |
| 2007年12月08日 22:29:25 | amaury.forgeotdarc | set | files:
+ kwonly.patch nosy: + amaury.forgeotdarc messages: + msg58301 |
| 2007年12月08日 22:12:49 | christian.heimes | set | status: open -> closed resolution: fixed |
| 2007年12月08日 22:12:41 | christian.heimes | set | nosy:
+ christian.heimes messages: + msg58300 |
| 2007年12月08日 18:14:13 | alexandre.vassalotti | set | versions: + Python 3.0 |
| 2007年12月08日 18:13:57 | alexandre.vassalotti | create | |