[Python-Dev] problem with genexp (original) (raw)
Jiwon Seo seojiwon at gmail.com
Mon Oct 17 10:59:20 CEST 2005
- Previous message: [Python-Dev] problem with genexp
- Next message: [Python-Dev] problem with genexp
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/16/05, Neal Norwitz <nnorwitz at gmail.com> wrote:
On 10/10/05, Neal Norwitz <nnorwitz at gmail.com> wrote: > There's a problem with genexp's that I think really needs to get > fixed. See http://python.org/sf/1167751 the details are below. This > code: > > >>> foo(a = i for i in range(10)) > > I agree with the bug report that the code should either raise a > SyntaxError or do the right thing.
The change to Grammar/Grammar below seems to fix the problem and all the tests pass. Can anyone comment on whether this fix is correct/appropriate? Is there a better way to fix the problem? -argument: [test '='] test [genfor] # Really [keyword '='] test +argument: test [genfor] | test '=' test ['(' genfor ')'] # Really [keyword '='] test
The other option would be changes in the Python/compile.c (somewhat) like following
diff -r2.352 compile.c 6356c6356,6362 - if (TYPE(n) == argument && NCH(n) == 3) {
if (TYPE(n) == argument && NCH(n) == 4) {
PyErr_SetString(PyExc_SyntaxError,
"invalid syntax");
symtable_error(st, n->n_lineno);
return;
}
else if (TYPE(n) == argument && NCH(n) == 3) {
but IMO, changing the Grammar looks more obvious.
n
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/seojiwon%40gmail.com
- Previous message: [Python-Dev] problem with genexp
- Next message: [Python-Dev] problem with genexp
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]