On Sun, May 12, 2013 at 2:01 PM, Antoine Pitrou <solipsis@pitrou.net> wrote:
On Fri, 03 May 2013 12:43:41 +1000 Steven D'Aprano <steve@pearwood.info> wrote:
On 03/05/13 11:29, Nick Coghlan wrote:
An exchange in one of the enum threads prompted me to write down something I've occasionally thought about regarding locals(): it is currently severely underspecified, and I'd like to make the current CPython behaviour part of the language/library specification. (We recently found a bug in the interaction between the __prepare__ method and lexical closures that was indirectly related to this underspecification)
Fixing the underspecification is good. Enshrining a limitation as the one correct way, not so good.
I have to say, I agree with Steven here. Mutating locals() is currently an implementation detail, and it should IMHO stay that way. Only reading a non-mutated locals() should be well-defined.
Regards
Antoine.
Like it or not, people rely on this behavior. I don't think CPython (or PyPy) can actually afford to change it. If so, documenting it sounds like a better idea than leaving it undocumented only known to the "inner shrine" Cheers, fijal