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.15:28:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1364311696.39.0.16992550443.issue17546@psf.upfronthosting.co.za>
In-reply-to
Content
So the problem you are having is that inside functions the dict returned by locals() does not get updated when the "current local symbol table" changes?  Keep in mind that for modules and classes (the other two execution blocks), the dict returned by locals() does get updated.

This difference reflects that fact that, in CPython at least, the local execution namespace of a function call's stack frame is not stored in a dictionary.  When you call locals() in a function it is only making a copy of the frame's fast locals.  The fast locals never gets directly exposed except through normal name lookup/binding/deletion.  While technically possible, changing this simply isn't worth it.

The documentation already makes it clear that the dict returned by locals() represents the "current local symbol table" and that you should not expect changes to that dict to be reflected in the actual locals.  Are you recommending that it be more clear that the dict may be no more than a snapshot of the locals at the time locals() is called?
History
Date User Action Args
2013-03-26 15:28:16eric.snowsetrecipients: + eric.snow, techtonik
2013-03-26 15:28:16eric.snowsetmessageid: <1364311696.39.0.16992550443.issue17546@psf.upfronthosting.co.za>
2013-03-26 15:28:16eric.snowlinkissue17546 messages
2013-03-26 15:28:16eric.snowcreate