Skip to content

fix(epy): ensure case-insensitive hash consistency in StrEnum - #849

Open
mohmedmm wants to merge 1 commit into
google:mainfrom
mohmedmm:fix-strenum-hash-consistency
Open

mohmedmm wants to merge 1 commit into
google:mainfrom
mohmedmm:fix-strenum-hash-consistency

Conversation

@mohmedmm

@mohmedmm mohmedmm commented Nov 3, 2026

Copy link
Copy Markdown

StrEnum overrides eq to compare case-insensitively, but hash delegated to super().hash(), leaving original casing in hashes and violating Python's equality/hash contract. Hashing self.value.lower() restores hash parity for matching enum members in sets and dicts, and populating _LOWER_TO_VAL lazily ensures member lookups work across all Python versions.

Fixes #843

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

epy.StrEnum case-insensitive equality violates hash consistency

1 participant