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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-90562: Improve zero argument support for
super()
in dataclasses whenslots=True
#124692base: main
Are you sure you want to change the base?
gh-90562: Improve zero argument support for
super()
in dataclasses whenslots=True
#124692Changes from 9 commits
3b65acf
efb6095
3654f51
19297bc
2606480
42f9dc3
53c18d1
96d5315
22eeb8f
e91c28b
4941a3f
6ef5317
d33070f
c26e978
d0173d8
c68b4cc
7d679f2
5bfea4d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the leading underscores on
_seen
and_depth
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should indicate that these arguments are only used within the function (in recursive calls) and not outside of the function body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the whole function is private, so it can only be used inside CPython by us :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you've got a point. Removed the underscores.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are depth 1 and 2 special? What is this test (and
_depth
in general) trying to accomplish? Please add comments explaining what's going on here, it's not at all clear from the code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an explanation and few test cases for this behaviour. Caught two bugs in the process \o/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case is always complex, since
getattr
can evaluate properties and other objects. There are two ways of hanling this case:I am not quite sure which one is better here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing this to my attention!
After some hacking, I've decided to go with the third option: removing any possibility of user defined code execution.