Skip to content
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-123935: Fix typo in _get_slots in dataclasses.py #123941

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Sep 11, 2024

Refs #118099

Local tests to better understand the problem / test. With this change:

from _testcapi import HeapCTypeWithDict, HeapCTypeWithWeakref
from dataclasses import _get_slots

assert list(_get_slots(HeapCTypeWithWeakref)) == ['__weakref__']
assert list(_get_slots(HeapCTypeWithDict)) == ['__dict__']

Without this change:

assert list(_get_slots(HeapCTypeWithWeakref)) == ['__weakref__', '__dict__']

But, since there's no public api to set __dict__ slot similar to weakref_slot, I had to use __dict__ as a field name. This is very ugly, I fully understand that. If prefered, I can remove the test completely.

Lib/test/test_dataclasses/__init__.py Outdated Show resolved Hide resolved
Lib/test/test_dataclasses/__init__.py Outdated Show resolved Hide resolved
@picnixz picnixz added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Sep 11, 2024
@sobolevn
Copy link
Member Author

Done! 👍

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@sobolevn sobolevn merged commit ac918cc into python:main Sep 12, 2024
36 checks passed
@miss-islington-app
Copy link

Thanks @sobolevn for the PR 🌮🎉.. 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 Sep 12, 2024
@bedevere-app
Copy link

bedevere-app bot commented Sep 12, 2024

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 12, 2024
@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 12, 2024
@bedevere-app
Copy link

bedevere-app bot commented Sep 12, 2024

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

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Sep 12, 2024
@sobolevn
Copy link
Member Author

Thank you! 🎉

sobolevn added a commit that referenced this pull request Sep 12, 2024
…3941) (#123992)

gh-123935: Fix typo in `_get_slots` in `dataclasses.py` (GH-123941)
(cherry picked from commit ac918cc)

Co-authored-by: sobolevn <[email protected]>
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.

3 participants