bpo-39728: Enum: fix duplicate ValueError (GH-22277)

fix default `_missing_` to return `None` instead of raising a `ValueError`
Co-authored-by: Andrey Darascheka <andrei.daraschenka@leverx.com>
This commit is contained in:
Ethan Furman 2020-09-16 10:26:50 -07:00 committed by GitHub
parent 83f6dcd207
commit c95ad7a91f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View file

@ -629,7 +629,7 @@ class Enum(metaclass=EnumMeta):
@classmethod
def _missing_(cls, value):
raise ValueError("%r is not a valid %s" % (value, cls.__qualname__))
return None
def __repr__(self):
return "<%s.%s: %r>" % (