Repository navigation
Restore hashability of Extension via eq=False (fix #5303) - #5349
Open
inchang-ing wants to merge 1 commit into
Open
inchang-ing wants to merge 1 commit into
inchang-ing wants to merge 1 commit into
Conversation
The dataclass conversion introduced in 84.0.0 generated __eq__ and therefore set __hash__ to None, making setuptools.extension.Extension unhashable and breaking setup scripts that collect extensions in sets or use them as dict keys (e.g. pywin32 CI builds). Pass eq=False to the lenient_dataclass decorator so Extension keeps its historical identity-based equality and hash. Fixes pypa#5303
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
setuptools.extension.Extensionbecame unhashable in 84.0.0: the dataclass conversion used the defaulteq=True, which generates__eq__and therefore forces__hash__toNone. Setup scripts that collect extensions in sets or use them as dict keys break outright (e.g. every pywin32 CI build currently fails withTypeError: unhashable type: 'WinExt_pythonwin').This passes
eq=Falseto thelenient_dataclassdecorator, soExtensionkeeps its historical identity-based equality and hash instead of gaining value equality.Fix
setuptools/_distutils/extension.py:@lenient_dataclass()→@lenient_dataclass(eq=False).Verification
setuptools/_distutils/tests/test_extension.py(test_extension_is_hashable,test_extension_hash_survives_set_membership).eq=Truemakestest_extension_is_hashablefail withTypeError: unhashable type: 'Extension'; with the fix it passes.Fixes #5303