Skip to content

gh-123935: Fix typo in _get_slots in dataclasses.py - #123941

Merged
sobolevn merged 3 commits into
python:mainfrom
sobolevn:issue-123935
Sep 12, 2024
Merged

gh-123935: Fix typo in _get_slots in dataclasses.py#123941
sobolevn merged 3 commits into
python:mainfrom
sobolevn:issue-123935

Conversation

@sobolevn

@sobolevnsobolevn commented Sep 11, 2024

Copy link
Copy Markdown
Member

Refs #118099

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

from_testcapiimportHeapCTypeWithDict, HeapCTypeWithWeakreffromdataclassesimport_get_slotsassertlist(_get_slots(HeapCTypeWithWeakref)) == ['__weakref__']
assertlist(_get_slots(HeapCTypeWithDict)) == ['__dict__']

Without this change:

assertlist(_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.

Comment threadLib/test/test_dataclasses/__init__.py Outdated
Comment threadLib/test/test_dataclasses/__init__.py Outdated
@picnixzpicnixz added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Sep 11, 2024
@sobolevn

Copy link
Copy Markdown
MemberAuthor

Done! 👍

@vstinnervstinner 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.

LGTM

@miss-islington-app

Copy link
Copy Markdown

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
…GH-123941)
(cherry picked from commit ac918cc)
Co-authored-by: sobolevn <mail@sobolevn.me>
@bedevere-app

Copy link
Copy Markdown

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
…GH-123941)
(cherry picked from commit ac918cc)
Co-authored-by: sobolevn <mail@sobolevn.me>
@bedevere-appbedevere-appBot removed the needs backport to 3.13 bugs and security fixes label Sep 12, 2024
@bedevere-app

Copy link
Copy Markdown

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

@bedevere-appbedevere-appBot removed the needs backport to 3.12 only security fixes label Sep 12, 2024
@sobolevn

Copy link
Copy Markdown
MemberAuthor

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 <mail@sobolevn.me>
Yhg1s pushed a commit that referenced this pull request Dec 3, 2024
…3941) (#123991)
gh-123935: Fix typo in `_get_slots` in `dataclasses.py` (GH-123941)
(cherry picked from commit ac918cc)
Co-authored-by: sobolevn <mail@sobolevn.me>
Sign up for freeto 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

@sobolevn@vstinner@picnixz