]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-100315: clarification to `__slots__` docs. (#102621)
authorT <tnie@tuta.io>
Tue, 14 Mar 2023 09:23:52 +0000 (17:23 +0800)
committerGitHub <noreply@github.com>
Tue, 14 Mar 2023 09:23:52 +0000 (09:23 +0000)
refer to tp_itemsize in discussion on "variable-length" built-in types

Doc/reference/datamodel.rst

index f447bbb1216d52dfba224a237b647de68f4a8883..1865d09fcaa1279b513ab1c5d60d320c3a39bd7b 100644 (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__*.