Enum by-value lookup no longer compares hashable argument to unhashable values #125710
Labels
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
needs backport to 3.13
bugs and security fixes
stdlib
Python modules in the Lib dir
type-bug
An unexpected behavior, bug, or error
Bug report
Bug description:
When defining enum members with hashable values (e.g.
frozenset
s), it was previously (prior to 3.13) possible to look those members up by passing in unhashable values (e.g.set
s) 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:
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.CPython versions tested on:
3.13
Operating systems tested on:
Windows
Linked PRs
The text was updated successfully, but these errors were encountered: