Message322681
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. |
|
Date |
User |
Action |
Args |
2018-07-30 17:36:39 | orlnub123 | set | recipients:
+ orlnub123, ethan.furman |
2018-07-30 17:36:39 | orlnub123 | set | messageid: <1532972199.25.0.56676864532.issue34282@psf.upfronthosting.co.za> |
2018-07-30 17:36:39 | orlnub123 | link | issue34282 messages |
2018-07-30 17:36:39 | orlnub123 | create | |
|