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

Nathaniel Smith report at bugs.python.org
Tue Jun 27 23:36:21 EDT 2017


Nathaniel Smith added the comment:

> Folks that actually *wanted* the old behaviour would then need to do either "sys._getframe().f_locals" or "inspect.currentframe().f_locals".

So by making locals() and f_locals have different semantics, we'd be adding yet another user-visible special-case? That seems unfortunate to me.

> if you want to write access to a function namespace from outside the function, you need to either implement an eval hook (not just a tracing hook)
[...]
> or else a decision to disallow write-backs to frame locals even from tracing functions in 3.7+.

Disallowing writeback from tracing functions would completely break bdb/pdb, so unless you're planning to rewrite bdb in C as an eval hook, then I don't think this is going to happen :-). Writing back to locals is a useful and important feature!

I think I'm missing some rationale here for why you prefer this approach – it seems much more complicated in terms of user-visible semantics, and possibly implementation-wise as well.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30744>
_______________________________________


More information about the Python-bugs-list mailing list