Skip to content

Incorrect slot check: typo in __dictoffset__ #123935

Description

@sobolevn

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

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directory
    on Sep 11, 2024
  2. self-assigned this
    on Sep 11, 2024
  3. picnixz commented on Sep 11, 2024

    @picnixz
    Member

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

  4. sobolevn commented on Sep 11, 2024

    @sobolevn
    MemberAuthor

    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 :)

  5. added 2 commits that reference this issue on Sep 11, 2024
  6. changed the title [-]Incorrect slot check: typo in `__dictoffest__`[/-] [+]Incorrect slot check: typo in `__dictoffset__`[/+] on Sep 11, 2024
  7. added a commit that references this issue on Sep 12, 2024
  8. added 2 commits that reference this issue on Sep 12, 2024
  9. added a commit that references this issue on Sep 12, 2024
  10. added a commit that references this issue on Dec 3, 2024
  11. hugovk commented on Jan 7, 2025

    @hugovk
    Member

    PR merged and backported 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13only security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-dataclassestype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions