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

Incorrect slot check: typo in __dictoffset__ #123935

Open
sobolevn opened this issue Sep 11, 2024 · 2 comments
Open

Incorrect slot check: typo in __dictoffset__ #123935

sobolevn opened this issue Sep 11, 2024 · 2 comments
Assignees
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes stdlib Python modules in the Lib dir topic-dataclasses type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Sep 11, 2024

Bug report

I made a typo that made it into the final code:

cpython/Lib/dataclasses.py

Lines 1211 to 1212 in 00ffdf2

if getattr(cls, '__dictrefoffset__', -1) != 0:
slots.append('__dict__')

It should had been __dictoffset__ not __dictrefoffset__.

Fixing plan:

  • Add tests for C types with __dictoffset__, so it won't happen again :)
  • Fix the typo

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir topic-dataclasses labels Sep 11, 2024
@sobolevn sobolevn self-assigned this Sep 11, 2024
@picnixz
Copy link
Contributor

picnixz commented Sep 11, 2024

Out of curiosity... how did you find it?

@sobolevn
Copy link
Member Author

I have a telegram channel, where I post different Python-related posts. Today I posted about how slots work in dataclasses. And one of my readers found this typo :)

sobolevn added a commit to sobolevn/cpython that referenced this issue Sep 11, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Sep 11, 2024
@sobolevn sobolevn changed the title Incorrect slot check: typo in __dictoffest__ Incorrect slot check: typo in __dictoffset__ Sep 11, 2024
@vstinner vstinner added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Sep 11, 2024
@picnixz picnixz added 3.12 bugs and security fixes 3.13 bugs and security fixes and removed needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Sep 11, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 12, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 12, 2024
sobolevn added a commit that referenced this issue 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
3.12 bugs and security fixes 3.13 bugs and security fixes stdlib Python modules in the Lib dir topic-dataclasses type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants