[issue22339] Incorrect behavior when subclassing enum.Enum

2014-09-04 Thread Kiss György
New submission from Kiss György: There is a small inconvenience in the ``enum`` module. When I subclass ``enum.Enum`` and redefine the ``value`` dynamic attribute, the aliasing behavior doesn't work correctly, because ``member.value`` is used in some places instead of ``member._value_

[issue22339] Incorrect behavior when subclassing enum.Enum

2014-09-04 Thread Kiss György
Kiss György added the comment: Yes, sorry I forgot about that. Here is a minimal example: from enum import EnumMeta, Enum from types import DynamicClassAttribute class _MultiMeta(EnumMeta): def __init__(enum_class, cls, bases, classdict): # make sure we only have tuple values

[issue22339] Incorrect behavior when subclassing enum.Enum

2014-09-05 Thread Kiss György
Kiss György added the comment: > Is this a way to easily handle multiple aliases? You mean this MultiValueEnum implementation? (If not I don't understand the question, could you elaborate?) No, this is the opposite of aliases, because an alias is when the same value have multiple na

[issue22339] Incorrect behavior when subclassing enum.Enum

2014-09-05 Thread Kiss György
Kiss György added the comment: Oh, wow. I never really understood what _find_new_ did, now I do. > I'm not sure what you are trying to accomplish there. Exactly that, I'm just not as good. Oh well at least I found a bug! :) Thanks for the enlightenment! If the patch goes in, I al

[issue22339] Incorrect behavior when subclassing enum.Enum

2014-09-06 Thread Kiss György
Kiss György added the comment: I found one thing which you can't do subclassing Enum what you can with metaclasses: enforcing type checking at class creation time. Values are passed to __new__ as positional arguments, so it's impossible to tell the difference between these t

[issue22339] Incorrect behavior when subclassing enum.Enum

2014-09-08 Thread Kiss György
Kiss György added the comment: Thanks for the tip! That looks much better. -- ___ Python tracker <http://bugs.python.org/issue22339> ___ ___ Python-bugs-list m