Message362496
Trying to instantiate an enum with an invalid value results in "During handling of the above exception, another exception occurred:". $ cat > test.py << EOF from enum import Enum class Color(Enum): RED = 1 GREEN = 2 BLUE = 3 Color(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__ return cls.__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_ raise ValueError("%r is not a valid %s" % (value, cls.__name__)) ValueError: 0 is not a valid Color I think this might be related to 019f0a0cb85e ("bpo-34536: raise error for invalid _missing_ results (GH-9147)"), but I haven't been able to confirm. | |
| Date | User | Action | Args | | 2020-02-23 09:07:04 | jonasmalaco | set | recipients: + jonasmalaco | | 2020-02-23 09:07:04 | jonasmalaco | set | messageid: <1582448824.79.0.766917894274.issue39728@roundup.psfhosted.org> | | 2020-02-23 09:07:04 | jonasmalaco | link | issue39728 messages | | 2020-02-23 09:07:04 | jonasmalaco | create | | |