python / python/cpython

Always check for `__dictrefoffset__` and `__weakoffset__` in `dataclasses` with slots

Open
#118,829 0 comments 1 reaction 1 assignee View on GitHub

@sobolevn is already working on this.

Since May 9, 2024.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

See https://github.com/python/cpython/pull/118099#discussion_r1575244611 and https://github.com/python/cpython/issues/118033

We now correctly check for __dictoffset__ and __weakoffset__ on C types without __slots__ defined: https://github.com/python/cpython/blob/c68acb1384a51eb745f572687eaf677371b9e765/Lib/dataclasses.py#L1201-L1212

But, not in this case: https://github.com/python/cpython/blob/c68acb1384a51eb745f572687eaf677371b9e765/Lib/dataclasses.py#L1213-L1218

So, in theory there might be C types with __slots__ and __dictoffset__ and __weakoffset__.

I will investigate!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.