Nick Coghlan added the comment:

After drafting PEP 558, briefly chatting about it to Guido, and sleeping on the 
topic, I'm wondering if there might be answer that's simpler than any of the 
alternatives consider so far: what if PyFrame_FastToLocals added the *cell 
objects* to f_locals for any variables that the compiler would access using 
LOAD/STORE_DEREF (rather than LOAD/STORE_FAST), and then PyFrame_LocalsToFast 
only wrote back the entries for variables that used LOAD/STORE_FAST?

That would be enough to fix the reported problems (since PyFrame_LocalsToFast 
would always leave closure variables alone in both the function defining the 
closure and the ones referencing it), and a trace hook that actually *wanted* 
to update the closure references could write to the "cell_contents" attribute 
on the cell of interest.

----------

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

Reply via email to