This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients eric.snow, techtonik
Date 2013-03-26.19:14:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1364325245.94.0.919011792128.issue17546@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-03-26 19:14:05eric.snowsetrecipients: + eric.snow, techtonik
2013-03-26 19:14:05eric.snowsetmessageid: <1364325245.94.0.919011792128.issue17546@psf.upfronthosting.co.za>
2013-03-26 19:14:05eric.snowlinkissue17546 messages
2013-03-26 19:14:05eric.snowcreate