New submission from Paul Pinterits <rawi...@gmail.com>:

In a conversation with Ethan Furman (the author of the enum module) I've been 
informed that Enum automatically checks whether the _missing_ method has 
returned an instance of the correct class, and raises a TypeError if not. 
(Link: https://stackoverflow.com/a/52064774/1222951)

However, this simply does not happen.

```
import enum

class MyEnum(enum.Enum):
    FOO = "foo"

    @classmethod
    def _missing_(cls, value):
        return 5

print(MyEnum('bar'))  # output: 5
```

----------
components: Library (Lib)
messages: 324282
nosy: Paul Pinterits
priority: normal
severity: normal
status: open
title: Enum._missing_ doesn't raise TypeError when a non-Enum object is a 
returned
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34536>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to