Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
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__')=TrueOn 3.12.3:
Token.__slots__=('ctx',)hasattr(Token, '__weakref__')=FalseCPython versions tested on:
3.12
Operating systems tested on:
Linux, macOS, Windows