Nick Coghlan <[email protected]> added the comment:
I'll also note there's a simpler reason the namespace object exposed at the
function level can't just be a write-through proxy for the underlying frame:
references to frame.f_locals may outlive the frame backing it, at which point
we really do want it to be a plain dictionary with no special behaviour, just
as it is for regular execution frames.
(Think "return locals()" as the last line in a helper function, as well as
variants like "data = locals(); data.pop('some_key'); return data")
That means that no matter what, we need to snapshot the frame locals the when
frame.f_locals is requested. The question then becomes:
- when we do we update the contents of cell references? (this is what's buggy
right now when a trace function is installed)
- when do we update ordinary local variables? (this isn't broken, so we want to
avoid changing it)
Providing write-through support *just* for cells should thus make it possible
to fix the buggy interaction between cells and trace function, while minimising
the risk of any unintended consequences affecting regular function locals.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue30744>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com