[New-bugs-announce] [issue29752] Enum._missing_ not called for __getattr__ failures

Ethan Furman report at bugs.python.org
Tue Mar 7 17:29:52 EST 2017


New submission from Ethan Furman:

class Label(Enum):

    RedApple = 1
    GreenApple = 2

    @classmethod
    def _missing_(cls, name):
        for member in cls:
            if member.name.lower() == name.lower():
                return member

Currently, _missing_ is only called when using the functional API. In words:

Label('redapple')  # works
Label.redapple     # does not

----------
assignee: ethan.furman
messages: 289191
nosy: barry, eli.bendersky, ethan.furman
priority: normal
severity: normal
stage: test needed
status: open
title: Enum._missing_ not called for __getattr__ failures
type: behavior
versions: Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29752>
_______________________________________


More information about the New-bugs-announce mailing list