[New-bugs-announce] [issue34536] Enum._missing_ doesn't raise TypeError when a non-Enum object is a returned
Paul Pinterits
report at bugs.python.org
Tue Aug 28 15:37:44 EDT 2018
New submission from Paul Pinterits <rawing7 at 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 <report at bugs.python.org>
<https://bugs.python.org/issue34536>
_______________________________________
More information about the New-bugs-announce
mailing list