-
- Notifications
You must be signed in to change notification settings - Fork 33.6k
Closed
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The __weakref__ slot is not set for classes that have a Generic[T] base.
from typing import Generic, TypeVar from dataclasses import dataclass T = TypeVar("T") @dataclass(slots=True, weakref_slot=True) class Token(Generic[T]): ctx: T print(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
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error