Message321361
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. |
|
Date |
User |
Action |
Args |
2018-07-10 07:31:59 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, georg.brandl, ajaksu2, kaizhu, John.McDonald, charettes, levkivskyi, Mariatta |
2018-07-10 07:31:59 | serhiy.storchaka | set | messageid: <1531207919.55.0.56676864532.issue3692@psf.upfronthosting.co.za> |
2018-07-10 07:31:59 | serhiy.storchaka | link | issue3692 messages |
2018-07-10 07:31:59 | serhiy.storchaka | create | |
|