[Python-checkins] gh-100315: clarification to `__slots__` docs. (#102621)

AlexWaygood webhook-mailer at python.org
Tue Mar 14 05:24:00 EDT 2023


https://github.com/python/cpython/commit/88c262c086077377b40dfae5e46f597e28ffe3c9
commit: 88c262c086077377b40dfae5e46f597e28ffe3c9
branch: main
author: T <tnie at tuta.io>
committer: AlexWaygood <Alex.Waygood at Gmail.com>
date: 2023-03-14T09:23:52Z
summary:

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

refer to tp_itemsize in discussion on "variable-length" built-in types

files:
M Doc/reference/datamodel.rst

diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index f447bbb1216d..1865d09fcaa1 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -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__*.
 



More information about the Python-checkins mailing list