[Python-Dev] Tightening up the specification for locals()

Antoine Pitrou solipsis at pitrou.net
Sun May 12 14:01:51 CEST 2013


On Fri, 03 May 2013 12:43:41 +1000
Steven D'Aprano <steve at 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.




More information about the Python-Dev mailing list