gh-100315: clarification to __slots__ docs. (#102621)

refer to tp_itemsize in discussion on "variable-length" built-in types
This commit is contained in:
T 2023-03-14 17:23:52 +08:00 committed by GitHub
parent 3d872a74c8
commit 88c262c086
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1944,8 +1944,10 @@ Notes on using *__slots__*
descriptor directly from the base class). This renders the meaning of the
program undefined. In the future, a check may be added to prevent this.
* Nonempty *__slots__* does not work for classes derived from "variable-length"
built-in types such as :class:`int`, :class:`bytes` and :class:`tuple`.
* :exc:`TypeError` will be raised if nonempty *__slots__* are defined for a
class derived from a
:c:member:`"variable-length" built-in type <PyTypeObject.tp_itemsize>` such as
:class:`int`, :class:`bytes`, and :class:`tuple`.
* Any non-string :term:`iterable` may be assigned to *__slots__*.