[issue17546] rename type returned by locals() to livedict

Eric Snow report at bugs.python.org
Tue Mar 26 20:14:05 CET 2013


Eric Snow added the comment:

Thanks for the details, Anatoly.  I am surprised by the behavior you've described.  It may be that functions don't use fast locals when tracing is turned on.  I'll have to check.  If that's the case, I think the documentation for locals() should be improved.  Either way, I agree that inconsistent (and undocumented) behavior is a headache.  However, changing the type of the object returned by locals() is going to take a lot more justification.  A doc update should be sufficient and a much easier sell.

Here are some further questions:

1. the dynamic update you described happens in function bodies (i.e. stack frames)?
2. does that behavior happen when you are not using a tracing function?

Also, if you have a minute, throw up a patch that reproduces the behavior you're talking about.  That will help get this resolved faster.

Keep in mind that locals() always returns a normal dict.  Just like any other dict, other code that has a reference to that "locals" dict can interact with it, which is what you have described.  In this case, the interpreter is doing so.  The only case where I find that surprising is where a stack frame is using fast locals, which is what function calls normally do.

----------

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


More information about the Python-bugs-list mailing list