diff options
author | Alex Waygood <Alex.Waygood@Gmail.com> | 2024-09-25 19:29:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-25 19:29:58 (GMT) |
commit | 0d9d56c4e4246495f506f7fb319548fb105b535b (patch) | |
tree | 09751f896776408a53ab935c4426289ff3d43d59 /Doc/extending | |
parent | 6318ffcba21f8fc155f5558237ab03aa45f0e174 (diff) | |
download | cpython-0d9d56c4e4246495f506f7fb319548fb105b535b.zip cpython-0d9d56c4e4246495f506f7fb319548fb105b535b.tar.gz cpython-0d9d56c4e4246495f506f7fb319548fb105b535b.tar.bz2 |
gh-101100: Add a table of class attributes to the "Custom classes" section of the data model docs (#124480)
Diffstat (limited to 'Doc/extending')
-rw-r--r-- | Doc/extending/newtypes.rst | 2 | ||||
-rw-r--r-- | Doc/extending/newtypes_tutorial.rst | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst index fd05c82..7f57a3a 100644 --- a/Doc/extending/newtypes.rst +++ b/Doc/extending/newtypes.rst @@ -296,7 +296,7 @@ An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` table descriptors that are used at runtime is that any attribute defined this way can have an associated doc string simply by providing the text in the table. An application can use the introspection API to retrieve the descriptor from the -class object, and get the doc string using its :attr:`!__doc__` attribute. +class object, and get the doc string using its :attr:`~type.__doc__` attribute. As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry with a :c:member:`~PyMethodDef.ml_name` value of ``NULL`` is required. diff --git a/Doc/extending/newtypes_tutorial.rst b/Doc/extending/newtypes_tutorial.rst index b8f437f..bcf938f 100644 --- a/Doc/extending/newtypes_tutorial.rst +++ b/Doc/extending/newtypes_tutorial.rst @@ -144,7 +144,7 @@ only used for variable-sized objects and should otherwise be zero. If you want your type to be subclassable from Python, and your type has the same :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have problems with multiple inheritance. A Python subclass of your type will have to list your type first - in its :attr:`~class.__bases__`, or else it will not be able to call your type's + in its :attr:`~type.__bases__`, or else it will not be able to call your type's :meth:`~object.__new__` method without getting an error. You can avoid this problem by ensuring that your type has a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its base type does. Most of the time, this will be true anyway, because either your |