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.

Author serhiy.storchaka
Recipients John.McDonald, Mariatta, ajaksu2, charettes, georg.brandl, gvanrossum, kaizhu, levkivskyi, serhiy.storchaka
Date 2018-07-10.07:31:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531207919.55.0.56676864532.issue3692@psf.upfronthosting.co.za>
In-reply-to
Content
Indeed, this issue is more complex than it looked to me.

Technically, LOAD_FAST, which is used for reading the loop
control variables in comprehensions, uses the array f->f_localsplus, while LOAD_NAME uses f->f_locals and f->f_globals. When executing class bodies, f->f_localsplus is NULL, and if executing functions f->f_locals usually is a NULL or a cached copy of a dict created from f->f_localsplus. But we can create a hybrid frame for comprehensions in class body, which will contain independent f->f_localsplus and f->f_locals. References to the loop
control variables and to the class variables will work as expected, just the meaning of locals() will be changed.
History
Date User Action Args
2018-07-10 07:31:59serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, georg.brandl, ajaksu2, kaizhu, John.McDonald, charettes, levkivskyi, Mariatta
2018-07-10 07:31:59serhiy.storchakasetmessageid: <1531207919.55.0.56676864532.issue3692@psf.upfronthosting.co.za>
2018-07-10 07:31:59serhiy.storchakalinkissue3692 messages
2018-07-10 07:31:59serhiy.storchakacreate