On Sat, Apr 27, 2013 at 2:27 PM, Ethan Furman <ethan@stoneleaf.us> wrote:
I filed bug http://bugs.python.org/issue17853 last night.
If somebody could point me in the right direction (mainly which files to look in), I'd be happy to attempt a patch.
Wow. I had no idea Python actually did this (override class-local references with ; I'd have expected your code to work. I was even more surprised to find that the same thing happens all the way back to Python 2.3. Guess I'm not nearly the wizard of abusing scope rules that I thought I was. ;-) About the only workaround I can see is to put "Season = Season" at the top of a class that uses this inside a function definition, or else to define a special name 'enum' instead and hope that nobody ever tries to define an enumeration inside a function with a local variable named 'enum'. ;-)