aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2020-09-16 17:38:14 -0700
committerGitHub <noreply@github.com>2020-09-16 17:38:14 -0700
commit5efb1a77e75648012f8b52960c8637fc296a5c6d (patch)
tree8cfbebff96a1ad92a8ab64f31ee24e923631babb /Lib/enum.py
parent_auto_called cleanup (GH-22285) (diff)
downloadcpython-5efb1a77e75648012f8b52960c8637fc296a5c6d.tar.gz
cpython-5efb1a77e75648012f8b52960c8637fc296a5c6d.tar.bz2
cpython-5efb1a77e75648012f8b52960c8637fc296a5c6d.zip
[3.8] bpo-39728: Enum: fix duplicate `ValueError` (GH-22277) (GH-22283)
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>
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index c2adfd1c6c0..de9ed4c1ec3 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -634,7 +634,7 @@ class Enum(metaclass=EnumMeta):
@classmethod
def _missing_(cls, value):
- raise ValueError("%r is not a valid %s" % (value, cls.__name__))
+ return None
def __repr__(self):
return "<%s.%s: %r>" % (