You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ethanfurman'closed_at=<Date2020-09-17.00:39:09.842>created_at=<Date2020-02-23.09:07:04.775>labels= ['3.8', 'type-bug', 'library', '3.9', '3.10']
title='Instantiating enum with invalid value results in ValueError twice'updated_at=<Date2020-09-17.00:39:09.841>user='https://github.com/jonasmalacofilho'
Trying to instantiate an enum with an invalid value results in "During handling of the above exception, another exception occurred:".
$ cat > test.py <<EOFfrom enum import Enum
classColor(Enum):
RED=1GREEN=2BLUE=3Color(0)
EOF
$ python --version
Python 3.8.1
$ python test.py
ValueError: 0 is not a valid Color
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 8, in <module>
Color(0)
File "/usr/lib/python3.8/enum.py", line 304, in __call__returncls.__new__(cls, value)
File "/usr/lib/python3.8/enum.py", line 595, in __new__raise exc
File "/usr/lib/python3.8/enum.py", line 579, in __new__
result =cls._missing_(value)
File "/usr/lib/python3.8/enum.py", line 608, in _missing_raiseValueError("%r is not a valid %s"% (value, cls.__name__))
ValueError: 0 is not a valid Color
I think this might be related to 019f0a0 ("bpo-34536: raise error for invalid _missing_ results (GH-9147)"), but I haven't been able to confirm.
ValueError
#22277ValueError
(GH-22277) #22282ValueError
(GH-22277) #22283Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: