Skip to content

gh-90562: Fix super() without args calls for dataclasses with slots - #111538

Open
sobolevn wants to merge 4 commits into
python:mainfrom
sobolevn:issue-111500
Open

gh-90562: Fix super() without args calls for dataclasses with slots#111538
sobolevn wants to merge 4 commits into
python:mainfrom
sobolevn:issue-111500

Conversation

@sobolevn

@sobolevnsobolevn commented Oct 31, 2023

Copy link
Copy Markdown
Member

@sobolevn

Copy link
Copy Markdown
MemberAuthor

@ericvsmith friendly ping :)

@JelleZijlstraJelleZijlstra changed the title gh-111500: Fix super() without args calls for dataclasses with slotsgh-90562: Fix super() without args calls for dataclasses with slotsMar 12, 2024
Comment threadLib/dataclasses.py

@serhiy-storchakaserhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for classmethod, staticmethod, property (with and without getter, setter and deleter), cached_property, normal method and method with some common decorator.

Comment threadLib/dataclasses.py
if isinstance(item, (classmethod, staticmethod)):
closure_cells = getattr(item.__func__, "__closure__", None)
elif isinstance(item, property):
closure_cells = getattr(item.fget, "__closure__", None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a getter doesn't have a closure, but a setter or deleter does?

Comment threadLib/dataclasses.py
Comment on lines +1238 to +1239
if isinstance(item, (classmethod, staticmethod)):
closure_cells = getattr(item.__func__, "__closure__", None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classmethod and staticmethod have the __wrapped__ attribute since 3.10, so this code is perhaps dead.

@serhiy-storchaka

Copy link
Copy Markdown
Member

and method with some common decorator.

For example partialmethod, singledispatchmethod and recursive_repr.

Oh, singledispatchmethod should be handled explicitly because, like property, it refers to multiple methods and closures should be fixed in all of them.

Then partial and singledispatch should probably also be supported, for static methods.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actionsgithub-actionsBot added the stale Stale PR or inactive for long period of time. label Apr 14, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviewstaleStale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@sobolevn@serhiy-storchaka@carljm@JelleZijlstra@AlexWaygood