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 orlnub123
Recipients ethan.furman, orlnub123
Date 2018-07-30.17:36:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1532972199.25.0.56676864532.issue34282@psf.upfronthosting.co.za>
In-reply-to
Content
If an enum has a member named _convert it gets shadowed by the _convert method as shown below.

>>> import enum
>>>
>>> class Test(enum.Enum):
...     _convert = enum.auto()
...
>>> Test._convert
<bound method Enum._convert of <enum 'Test'>>

I've came up with a couple of solutions:

1. Add _convert to the invalid names list, next to mro
2. Rename _convert to _convert_ as sunder names are reserved
3. Move _convert to the metaclass

I think the first solution would be the worst as it would break existing enums that have _convert as a member (although unusable).

The problem with the second solution would be breaking external code that uses it although I think that's a moot point as it's meant for internal use. Another shortcoming would be having to update all the stdlib code that uses it.

The third solution might be a bit confusing on its own if an existing enum with a _convert member suddenly removed it leaving you with a bound method instead of raising an AttributeError.
History
Date User Action Args
2018-07-30 17:36:39orlnub123setrecipients: + orlnub123, ethan.furman
2018-07-30 17:36:39orlnub123setmessageid: <1532972199.25.0.56676864532.issue34282@psf.upfronthosting.co.za>
2018-07-30 17:36:39orlnub123linkissue34282 messages
2018-07-30 17:36:39orlnub123create