Skip to content

Fix intermediate __setattr__ handling in mixed inheritance chains#1567

Open
sahvx655-wq wants to merge 4 commits into
python-attrs:mainfrom
sahvx655-wq:fix/setattr-reset-intermediate-classes
Open

Fix intermediate __setattr__ handling in mixed inheritance chains#1567
sahvx655-wq wants to merge 4 commits into
python-attrs:mainfrom
sahvx655-wq:fix/setattr-reset-intermediate-classes

Conversation

@sahvx655-wq
Copy link
Copy Markdown

This PR fixes a correctness issue in attrs where setattr could be incorrectly overridden when using intermediate base classes that define a custom setattr.

Previously, only immediate base classes were checked, which caused custom setattr implementations in deeper inheritance hierarchies to be ignored or replaced unexpectedly.

This change introduces MRO-based resolution for both slotted and dict-based classes, ensuring that intermediate setattr implementations are properly respected throughout the inheritance chain.

Adds and updates tests covering multiple inheritance and edge-case hierarchies to validate the fix. is this matches for this title Fix intermediate setattr handling in mixed inheritance chains

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.

1 participant