Issue1573
Created on 2007-12-08 18:13 by alexandre.vassalotti, last changed 2008-01-06 22:29 by admin.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
kwonly.patch
|
amaury.forgeotdarc,
2007-12-08 22:29
|
|
|
|
|
kwonly2.patch
|
amaury.forgeotdarc,
2007-12-08 23:50
|
|
|
|
|
msg58299 - (view) |
Author: Alexandre Vassalotti (alexandre.vassalotti) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
Date: 2007-12-09 21:50 |
|
Committed revision 59443.
|
|
| Date |
User |
Action |
Args |
| 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 | |
|