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 ethan.furman
Recipients arigo, ethan.furman, terry.reedy
Date 2014-05-19.03:08:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1400468900.39.0.201599610046.issue19979@psf.upfronthosting.co.za>
In-reply-to
Content
Terry remarked:
---------------
> I am puzzled by the opening statement there that
>
>   from enum import Enum  # I added this as necessary
>   class Season(Enum):
>       SPRING = Season()
>
> "works beautifully" at top level as it indeed raises
> NameError: name 'Season' is not defined

Pay close attention to the line just before that example:

> 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.

It does not raise a NameError because the name was injected via the metaclass __prepare__ method.  (Or did at that time -- I don't think that bit of cleverness made the final cut.)

As far as this enhancement request goes, I think the compatibility break is likely too large to have it in the 3.x series.
History
Date User Action Args
2014-05-19 03:08:20ethan.furmansetrecipients: + ethan.furman, arigo, terry.reedy
2014-05-19 03:08:20ethan.furmansetmessageid: <1400468900.39.0.201599610046.issue19979@psf.upfronthosting.co.za>
2014-05-19 03:08:20ethan.furmanlinkissue19979 messages
2014-05-19 03:08:19ethan.furmancreate