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
{{ message }}
Repository navigation
Enum by-value lookup no longer compares hashable argument to unhashable values #125710
When defining enum members with hashable values (e.g. frozensets), it was previously (prior to 3.13) possible to look those members up by passing in unhashable values (e.g. sets) that compare equal to those original values.
This no longer works as of 3.13 (specifically GH-112514), since the unhashable argument is now only compared to unhashable enum values. I haven't been able to find any documentation of this change in the What's New or even the changelog, so I'm assuming it's not entirely intended.
Reproducible example:
fromenumimportEnumclassDirections(Enum):
DOWN_ONLY=frozenset({"sc"})
UP_ONLY=frozenset({"cs"})
UNRESTRICTED=frozenset({"sc", "cs"})
dirs= {"sc"}
# in 3.13, this raises ValueErrorthe_dirs=Directions(dirs)
assertthe_dirsisDirections.DOWN_ONLY
Note that in this example (which is based on our use case) there's the obvious user-side fix of Directions(frozenset(dirs)), but if there happens to be another hashable-equal-to-unhashable use case outside of (frozen)sets, such a workaround might not exist.
Activity
generate_packets.py: Fix crash under Python 3.13
generate_packets.py: Fix crash under Python 3.13
generate_packets.py: Fix crash under Python 3.13
gh-125710: [Enum] fix hashable<->nonhashable comparisons for member v…
pythongh-125710: [Enum] fix hashable<->nonhashable comparisons for me…
[3.13] gh-125710: [Enum] fix hashable<->nonhashable comparisons for m…
pythongh-125710: [Enum] fix hashable<->nonhashable comparisons for me…
generate_packets.py: Fix crash under Python 3.13