Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue3692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to