[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Ethan Furman
Ethan Furman added the comment: I guess the question is: Because Python can no longer know if the name has been inserted via __prepare__ it has to go through the whole CLOSURE business, but will changing the LOAD_DEREF to a LOAD_GLOBAL (only for items inside a class def) do the trick? --

[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Ethan Furman
Ethan Furman added the comment: On 04/27/2013 02:01 PM, Mark Dickinson wrote: > > Mark Dickinson added the comment: > > Isn't this just a consequence of Python's usual name-lookup rules? In this > code: > > def test(): > class Season(Enum): > SPRING = Season() > > the

[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Mark Dickinson
Mark Dickinson added the comment: Isn't this just a consequence of Python's usual name-lookup rules? In this code: def test(): class Season(Enum): SPRING = Season() the class definition in 'test' amounts to a local assignment to the name 'Season'. So the occurrence o

[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Daniel Urban
Changes by Daniel Urban : -- nosy: +daniel.urban ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Ethan Furman
Ethan Furman added the comment: One more data point to truly demonstrate that something is wrong: --> def test(): ... class Season(Enum): ... print(locals()) ... Season = locals()['Season'] ... print(locals()) ... --> test() {'Season': ,

[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Ethan Furman
New submission from Ethan Furman: In playing with metaclasses for the ongoing Enum saga, I tried having the metaclass insert an object into the custom dict (aka namespace) returned by __prepare__; this object has the same name as the to-be-created class. An example: class Season(Enum): SP