[2.7] bpo-10544: Deprecate "yield" in comprehensions and generator expressions in Py3k mode. (GH-4579) by serhiy-storchaka · Pull Request #4676 · python/cpython

@serhiy-storchaka

@serhiy-storchaka

@ncoghlan

ncoghlan

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, just one request for an explanatory comment on the new list comp checking code.

{
asdl_seq *generators = e->v.ListComp.generators;
int i;
int is_generator = st->st_cur->ste_generator;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed the addition of is_generator on my first read-through of this function, so I think it could use an explanatory comment. Something like:

/* In order to check for yield expressions under '-3', we clear the generator flag, and restore it at the end */

@serhiy-storchaka

@serhiy-storchaka

@mjpieters

This is on the 2.7 branch, not the 3.7 branch. In 3.7b1 this is currently not a deprecation warning. Wrong branch perhaps?

@serhiy-storchaka

@mjpieters

Excellent, thanks! I was confused because I missed that 3.7 was still the master branch when the first commit went in, the separate 3.7 branch had yet to be cut.

See #4579 for 3.7 and #4676 for 3.8.

<mode demeanor="pedant">#4676 is this PR :-) The 3.8 SyntaxError change is #4564.</mode>

Thanks again!