Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

dataclasses: 3.12.3 regression withweakref_slot #118033

Closed
Labels
3.12only security fixes3.13bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@francis-clairicia

Description

@francis-clairicia

Bug report

Bug description:

The__weakref__ slot is not set for classes that have aGeneric[T] base.

fromtypingimportGeneric,TypeVarfromdataclassesimportdataclassT=TypeVar("T")@dataclass(slots=True,weakref_slot=True)classToken(Generic[T]):ctx:Tprint(f"{Token.__slots__=!r}")print(f"{hasattr(Token,'__weakref__')=}")

Output on 3.12.2:

Token.__slots__=('ctx', '__weakref__')hasattr(Token, '__weakref__')=True

On 3.12.3:

Token.__slots__=('ctx',)hasattr(Token, '__weakref__')=False

CPython versions tested on:

3.12

Operating systems tested on:

Linux, macOS, Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp