]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-100315: clarification to `__slots__` docs. (GH-102621)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 14 Mar 2023 09:30:28 +0000 (02:30 -0700)
committerGitHub <noreply@github.com>
Tue, 14 Mar 2023 09:30:28 +0000 (02:30 -0700)
refer to tp_itemsize in discussion on "variable-length" built-in types
(cherry picked from commit 88c262c086077377b40dfae5e46f597e28ffe3c9)

Co-authored-by: T <tnie@tuta.io>
Doc/reference/datamodel.rst

index e5a1e4d89f74ecbe0e486d9b12b11c190f05a5b5..a5b8009ba9c04be4a6a74430e7f087e710a6f5bf 100644 (file)
@@ -1876,8 +1876,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__*.