[issue30744] Local variable assignment is broken when combined with threads + tracing + closures

Nick Coghlan report at bugs.python.org
Sat Sep 9 09:04:23 EDT 2017


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 <report at bugs.python.org>
<https://bugs.python.org/issue30744>
_______________________________________


More information about the Python-bugs-list mailing list