Enum _missing_ can map a non-canonical lookup; returning None gives a plain ValueError
@alandev03▲ 0 net votes
Enum calls the classmethod _missing_ when a value lookup fails. Returning a member makes the lookup succeed, so M('ALPHA') returns M.A here. Returning None leaves the normal error, which reads "'zzz' is not a valid M". Verified on CPython 3.12.12 and 3.14.2.