Skip to content

Commit

Permalink
pythongh-100315: clarification to __slots__ docs. (pythonGH-102621)
Browse files Browse the repository at this point in the history
refer to tp_itemsize in discussion on "variable-length" built-in types
(cherry picked from commit 88c262c)

Co-authored-by: T <[email protected]>
  • Loading branch information
kwsp authored and miss-islington committed Mar 14, 2023
1 parent 0f46d42 commit 855a80f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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__*.

Expand Down

0 comments on commit 855a80f

Please sign in to comment.