← 返回首页
gh-90562: Mention slots pitfall in dataclass docs by thejcannon · Pull Request #107391 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

gh-90562: Mention slots pitfall in dataclass docs#107391

Merged
hugovk merged 10 commits into
python:mainfrom
thejcannon:patch-1
May 21, 2024
Merged

gh-90562: Mention slots pitfall in dataclass docs#107391
hugovk merged 10 commits into
python:mainfrom
thejcannon:patch-1

Conversation

thejcannon commented Jul 28, 2023
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Contributor

Doesn't fix the issue, but does call it out so developers know that the issue doesn't lie with them (per-se) and gives them more info on where to go.

Will need to be backported to 3.10 and 3.11.

📚 Documentation preview 📚: https://cpython-previews--107391.org.readthedocs.build/

Copy link
Copy Markdown
Member

I can't say I've seen something like this documented before. I'd like to get some more opinions on it.

Copy link
Copy Markdown
Contributor Author

Yeah. If the exception was more clear, maybe it wouldn't be warranted. But it took me longer than I want to admit to put two-and-two together. And then, because I'm super nosy I was able to find the linked issue.

So I feel for the little guy who has to piece it all together. (Speaking of, I should edit to suggest the workaround, the "old-style" super call)

AA-Turner added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Jul 28, 2023
Comment thread Doc/library/dataclasses.rst Outdated
is raised. Calling no-arg ``super()`` in dataclasses using ``slots=True`` will result in
the following Exception being raised:
``TypeError: super(type, obj): obj must be an instance or subtype of type``.
The two-arg ``super()`` is a valid workaround. See :issue:`46404` for full details.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

We should try to capture everything relevant in the documentation -- what is relevant to the reader from the linked issue that isn't captured in your summary?

A

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

I think these two points are it. What to look for and how to workaround.

carljm commented Jul 28, 2023

Copy link
Copy Markdown
Member

I feel like early in my CPython contribution I remember someone saying "we don't document bugs, we fix them."

But I'm also sympathetic to the point of view that this is a significant limitation that people are likely to hit and with an extremely confusing symptom, and there's no clear fix for it on the horizon, and it would be kinder to our users to surface it in the docs.

So while it bugs me slightly, on the whole I think I'm in favor of this. I'll leave the final say to our documentation experts (and @ericvsmith as dataclasses expert.)

wookie184 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

This seems sensible to me. It took me a while to find out what was going on when I encountered this issue.

Comment thread Doc/library/dataclasses.rst Outdated Show resolved Hide resolved
thejcannon and others added 2 commits August 7, 2023 12:02
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Comment thread Doc/library/dataclasses.rst Outdated Show resolved Hide resolved
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

hugovk commented Apr 11, 2024

Copy link
Copy Markdown
Member

(This now has a merge conflict.)

serhiy-storchaka added the needs backport to 3.13 bugs and security fixes label May 9, 2024
Comment thread Doc/library/dataclasses.rst Outdated Show resolved Hide resolved
hugovk enabled auto-merge (squash) May 21, 2024 12:06
hugovk merged commit e3ed574 into python:main May 21, 2024

Copy link
Copy Markdown

Thanks @thejcannon for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 21, 2024
) (cherry picked from commit e3ed574) Co-authored-by: Josh Cannon <joshdcannon@gmail.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 21, 2024
) (cherry picked from commit e3ed574) Co-authored-by: Josh Cannon <joshdcannon@gmail.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

bedevere-app Bot commented May 21, 2024

Copy link
Copy Markdown

GH-119350 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label May 21, 2024

bedevere-app Bot commented May 21, 2024

Copy link
Copy Markdown

GH-119351 is a backport of this pull request to the 3.12 branch.

bedevere-app Bot removed the needs backport to 3.12 only security fixes label May 21, 2024
thejcannon deleted the patch-1 branch May 21, 2024 19:43

Copy link
Copy Markdown
Contributor Author

Huzzah! 🎉

hugovk added a commit that referenced this pull request May 23, 2024
…119350) Co-authored-by: Josh Cannon <joshdcannon@gmail.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
hugovk added a commit that referenced this pull request May 23, 2024
…119351) Co-authored-by: Josh Cannon <joshdcannon@gmail.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

e-gebes commented Jun 19, 2024

Copy link
Copy Markdown

Could you backport this also to the 3.10 docs? I ran into the issue, and since I need to use 3.10 atm I read the 3.10 docs.

hugovk commented Jun 19, 2024

Copy link
Copy Markdown
Member

Sorry, 3.10 and 3.11 are only allowed to have security fixes: https://devguide.python.org/versions/

estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Erlend E. Aasland <erlend@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
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

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Footer

© 2026 GitHub, Inc.