[3.9] bpo-39728: Enum: fix duplicate `ValueError` (GH-22277) (GH-22282)
fix default `_missing_` to return `None` instead of raising a `ValueError`
Co-authored-by: Andrey Darascheka <andrei.daraschenka@leverx.com>
(cherry picked from commit c95ad7a91fbd7636f33a098d3b39964ab083bf49)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
diff --git a/Lib/enum.py b/Lib/enum.py
index da5a31f..ebadd9f 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -628,7 +628,7 @@
@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>" % (