[Python-Dev] problem with genexp
Jiwon Seo
seojiwon at gmail.com
Tue Feb 21 00:55:19 CET 2006
Regarding this Grammar change; (last October)
from argument: [test '=' ] test [gen_for]
to argument: test [gen_for] | test '=' test ['(' gen_for ')']
- to raise error for "bar(a = i for i in range(10)) )"
I think we should change it to
argument: test [gen_for] | test '=' test
instead of
argument: test [gen_for] | test '=' test ['(' gen_for ')']
that is, without ['(' gen_for ')'] . We don't need that extra term,
because "test" itself includes generator expressions - with all those
parensises.
Actually with that extra ['(' gen_for ')'] , foo(a= 10 (for y in
'a')) is grammartically correct ; although that error seems to be
checked elsewhere.
I tested without ['(' gen_for ')'] , and worked fine passing
Lib/test/test_genexps.py
-Jiwon
On 10/20/05, Neal Norwitz <nnorwitz at gmail.com> wrote:
> 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?
>
> Since no one responded other than Jiwon, I checked in this change. I
> did *not* backport it since what was syntactically correct in 2.4.2
> would raise an error in 2.4.3. I'm not sure which is worse. I'll
> leave it up to Anthony whether this should be backported.
>
> BTW, the change was the same regardless of old code vs. new AST code.
>
> 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
>
More information about the Python-Dev
mailing list