Skip to content

Commit 1858649

Browse files
gh-107298: Fix yet more Sphinx warnings in the C API doc
1 parent f84d77b commit 1858649

13 files changed

+45
-34
lines changed

Doc/c-api/capsule.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Refer to :ref:`using-capsules` for more information on using these objects.
121121
compared.)
122122
123123
In other words, if :c:func:`PyCapsule_IsValid` returns a true value, calls to
124-
any of the accessors (any function starting with :c:func:`PyCapsule_Get`) are
124+
any of the accessors (any function starting with ``PyCapsule_Get``) are
125125
guaranteed to succeed.
126126
127127
Return a nonzero value if the object is valid and matches the name passed in.

Doc/c-api/init_config.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ PyStatus
135135
136136
Name of the function which created an error, can be ``NULL``.
137137
138+
.. c:namespace:: NULL
139+
138140
Functions to create a status:
139141
140142
.. c:function:: PyStatus PyStatus_Ok(void)
@@ -210,6 +212,8 @@ PyPreConfig
210212
211213
Structure used to preinitialize Python.
212214
215+
.. c:namespace:: NULL
216+
213217
Function to initialize a preconfiguration:
214218
215219
.. c:function:: void PyPreConfig_InitPythonConfig(PyPreConfig *preconfig)
@@ -222,6 +226,8 @@ PyPreConfig
222226
Initialize the preconfiguration with :ref:`Isolated Configuration
223227
<init-isolated-conf>`.
224228
229+
.. c:namespace:: PyPreConfig
230+
225231
Structure fields:
226232
227233
.. c:member:: int allocator
@@ -429,6 +435,8 @@ PyConfig
429435
When done, the :c:func:`PyConfig_Clear` function must be used to release the
430436
configuration memory.
431437
438+
.. c:namespace:: NULL
439+
432440
Structure methods:
433441
434442
.. c:function:: void PyConfig_InitPythonConfig(PyConfig *config)
@@ -527,6 +535,8 @@ PyConfig
527535
The caller of these methods is responsible to handle exceptions (error or
528536
exit) using ``PyStatus_Exception()`` and ``Py_ExitStatusException()``.
529537
538+
.. c:namespace:: PyConfig
539+
530540
Structure fields:
531541
532542
.. c:member:: PyWideStringList argv
@@ -938,7 +948,7 @@ PyConfig
938948
.. c:member:: wchar_t* pythonpath_env
939949
940950
Module search paths (:data:`sys.path`) as a string separated by ``DELIM``
941-
(:data:`os.path.pathsep`).
951+
(:data:`os.pathsep`).
942952
943953
Set by the :envvar:`PYTHONPATH` environment variable.
944954

Doc/c-api/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ and lose important information about the exact cause of the error.
616616
.. index:: single: sum_sequence()
617617

618618
A simple example of detecting exceptions and passing them on is shown in the
619-
:c:func:`sum_sequence` example above. It so happens that this example doesn't
619+
:c:func:`!sum_sequence` example above. It so happens that this example doesn't
620620
need to clean up any owned references when it detects an error. The following
621621
example function shows some error cleanup. First, to remind you why you like
622622
Python, we show the equivalent Python code::

Doc/c-api/memory.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ Customize Memory Allocators
431431
432432
Enum used to identify an allocator domain. Domains:
433433
434+
.. c:namespace:: NULL
435+
434436
.. c:macro:: PYMEM_DOMAIN_RAW
435437
436438
Functions:

Doc/c-api/module.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Module Objects
119119
encoded to 'utf-8'.
120120
121121
.. deprecated:: 3.2
122-
:c:func:`PyModule_GetFilename` raises :c:type:`UnicodeEncodeError` on
122+
:c:func:`PyModule_GetFilename` raises :exc:`UnicodeEncodeError` on
123123
unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead.
124124
125125

Doc/c-api/none.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The ``None`` Object
99

1010
Note that the :c:type:`PyTypeObject` for ``None`` is not directly exposed in the
1111
Python/C API. Since ``None`` is a singleton, testing for object identity (using
12-
``==`` in C) is sufficient. There is no :c:func:`PyNone_Check` function for the
12+
``==`` in C) is sufficient. There is no :c:func:`!PyNone_Check` function for the
1313
same reason.
1414

1515

Doc/c-api/object.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ Object Protocol
293293
294294
Normally only class objects, i.e. instances of :class:`type` or a derived
295295
class, are considered classes. However, objects can override this by having
296-
a :attr:`__bases__` attribute (which must be a tuple of base classes).
296+
a :attr:`~class.__bases__` attribute (which must be a tuple of base classes).
297297
298298
299299
.. c:function:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)
@@ -310,10 +310,10 @@ Object Protocol
310310
is an instance of *cls* if its class is a subclass of *cls*.
311311
312312
An instance *inst* can override what is considered its class by having a
313-
:attr:`__class__` attribute.
313+
:attr:`~instance.__class__` attribute.
314314
315315
An object *cls* can override if it is considered a class, and what its base
316-
classes are, by having a :attr:`__bases__` attribute (which must be a tuple
316+
classes are, by having a :attr:`~class.__bases__` attribute (which must be a tuple
317317
of base classes).
318318
319319

Doc/c-api/set.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ or :class:`frozenset` or instances of their subtypes.
110110
.. index:: pair: built-in function; len
111111
112112
Return the length of a :class:`set` or :class:`frozenset` object. Equivalent to
113-
``len(anyset)``. Raises a :exc:`PyExc_SystemError` if *anyset* is not a
113+
``len(anyset)``. Raises a :exc:`SystemError` if *anyset* is not a
114114
:class:`set`, :class:`frozenset`, or an instance of a subtype.
115115
116116
@@ -124,7 +124,7 @@ or :class:`frozenset` or instances of their subtypes.
124124
Return ``1`` if found, ``0`` if not found, and ``-1`` if an error is encountered. Unlike
125125
the Python :meth:`~object.__contains__` method, this function does not automatically
126126
convert unhashable sets into temporary frozensets. Raise a :exc:`TypeError` if
127-
the *key* is unhashable. Raise :exc:`PyExc_SystemError` if *anyset* is not a
127+
the *key* is unhashable. Raise :exc:`SystemError` if *anyset* is not a
128128
:class:`set`, :class:`frozenset`, or an instance of a subtype.
129129
130130
@@ -149,7 +149,7 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
149149
error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a
150150
:exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard`
151151
method, this function does not automatically convert unhashable sets into
152-
temporary frozensets. Raise :exc:`PyExc_SystemError` if *set* is not an
152+
temporary frozensets. Raise :exc:`SystemError` if *set* is not an
153153
instance of :class:`set` or its subtype.
154154
155155

Doc/c-api/sys.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Operating System Utilities
167167
168168
.. versionchanged:: 3.8
169169
The function now uses the UTF-8 encoding on Windows if
170-
:c:member:`PyConfig.legacy_windows_fs_encoding` is zero;
170+
:c:member:`PyPreConfig.legacy_windows_fs_encoding` is zero;
171171
172172
173173
.. c:function:: char* Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
@@ -209,7 +209,7 @@ Operating System Utilities
209209
210210
.. versionchanged:: 3.8
211211
The function now uses the UTF-8 encoding on Windows if
212-
:c:member:`PyConfig.legacy_windows_fs_encoding` is zero.
212+
:c:member:`PyPreConfig.legacy_windows_fs_encoding` is zero.
213213
214214
215215
.. _systemfunctions:

Doc/c-api/type.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Type Objects
103103
:c:func:`PyType_AddWatcher` will be called whenever
104104
:c:func:`PyType_Modified` reports a change to *type*. (The callback may be
105105
called only once for a series of consecutive modifications to *type*, if
106-
:c:func:`PyType_Lookup` is not called on *type* between the modifications;
106+
:c:func:`_PyType_Lookup` is not called on *type* between the modifications;
107107
this is an implementation detail and subject to change.)
108108
109109
An extension should never call ``PyType_Watch`` with a *watcher_id* that was

Doc/c-api/typeobj.rst

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ PyObject Slots
485485
--------------
486486

487487
The type object structure extends the :c:type:`PyVarObject` structure. The
488-
:c:member:`~PyVarObject.ob_size` field is used for dynamic types (created by :func:`type_new`,
488+
:c:member:`~PyVarObject.ob_size` field is used for dynamic types (created by :c:func:`!type_new`,
489489
usually called from a class statement). Note that :c:data:`PyType_Type` (the
490490
metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its instances (i.e.
491491
type objects) *must* have the :c:member:`~PyVarObject.ob_size` field.
@@ -740,7 +740,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
740740
Before version 3.12, it was not recommended for
741741
:ref:`mutable heap types <heap-types>` to implement the vectorcall
742742
protocol.
743-
When a user sets :attr:`~type.__call__` in Python code, only *tp_call* is
743+
When a user sets :attr:`~object.__call__` in Python code, only *tp_call* is
744744
updated, likely making it inconsistent with the vectorcall function.
745745
Since 3.12, setting ``__call__`` will disable vectorcall optimization
746746
by clearing the :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag.
@@ -1369,8 +1369,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
13691369
The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage collector to detect
13701370
reference cycles. A typical implementation of a :c:member:`~PyTypeObject.tp_traverse` function
13711371
simply calls :c:func:`Py_VISIT` on each of the instance's members that are Python
1372-
objects that the instance owns. For example, this is function :c:func:`local_traverse` from the
1373-
:mod:`_thread` extension module::
1372+
objects that the instance owns. For example, this is function :c:func:`!local_traverse` from the
1373+
:mod:`!_thread` extension module::
13741374

13751375
static int
13761376
local_traverse(localobject *self, visitproc visit, void *arg)
@@ -1721,7 +1721,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
17211721
called; it may also be initialized to a dictionary containing initial attributes
17221722
for the type. Once :c:func:`PyType_Ready` has initialized the type, extra
17231723
attributes for the type may be added to this dictionary only if they don't
1724-
correspond to overloaded operations (like :meth:`__add__`). Once
1724+
correspond to overloaded operations (like :meth:`~object.__add__`). Once
17251725
initialization for the type has finished, this field should be
17261726
treated as read-only.
17271727

@@ -1818,7 +1818,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
18181818
**Default:**
18191819

18201820
This slot has no default. For :ref:`static types <static-types>`, if the
1821-
field is ``NULL`` then no :attr:`__dict__` gets created for instances.
1821+
field is ``NULL`` then no :attr:`~object.__dict__` gets created for instances.
18221822

18231823
If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the
18241824
:c:member:`~PyTypeObject.tp_dict` field, then
@@ -1830,18 +1830,18 @@ and :c:data:`PyType_Type` effectively act as defaults.)
18301830
18311831
An optional pointer to an instance initialization function.
18321832

1833-
This function corresponds to the :meth:`__init__` method of classes. Like
1834-
:meth:`__init__`, it is possible to create an instance without calling
1835-
:meth:`__init__`, and it is possible to reinitialize an instance by calling its
1836-
:meth:`__init__` method again.
1833+
This function corresponds to the :meth:`~object.__init__` method of classes. Like
1834+
:meth:`!__init__`, it is possible to create an instance without calling
1835+
:meth:`!__init__`, and it is possible to reinitialize an instance by calling its
1836+
:meth:`!__init__` method again.
18371837

18381838
The function signature is::
18391839

18401840
int tp_init(PyObject *self, PyObject *args, PyObject *kwds);
18411841

18421842
The self argument is the instance to be initialized; the *args* and *kwds*
18431843
arguments represent positional and keyword arguments of the call to
1844-
:meth:`__init__`.
1844+
:meth:`~object.__init__`.
18451845

18461846
The :c:member:`~PyTypeObject.tp_init` function, if not ``NULL``, is called when an instance is
18471847
created normally by calling its type, after the type's :c:member:`~PyTypeObject.tp_new` function
@@ -2130,7 +2130,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
21302130
In other words, it is used to implement
21312131
:ref:`vectorcall <vectorcall>` for ``type.__call__``.
21322132
If ``tp_vectorcall`` is ``NULL``, the default call implementation
2133-
using :attr:`__new__` and :attr:`__init__` is used.
2133+
using :meth:`~object.__new__` and :meth:`~object.__init__` is used.
21342134

21352135
**Inheritance:**
21362136

@@ -2329,8 +2329,8 @@ Mapping Object Structures
23292329
.. c:member:: objobjargproc PyMappingMethods.mp_ass_subscript
23302330
23312331
This function is used by :c:func:`PyObject_SetItem`,
2332-
:c:func:`PyObject_DelItem`, :c:func:`PyObject_SetSlice` and
2333-
:c:func:`PyObject_DelSlice`. It has the same signature as
2332+
:c:func:`PyObject_DelItem`, :c:func:`PySequence_SetSlice` and
2333+
:c:func:`PySequence_DelSlice`. It has the same signature as
23342334
:c:func:`!PyObject_SetItem`, but *v* can also be set to ``NULL`` to delete
23352335
an item. If this slot is ``NULL``, the object does not support item
23362336
assignment and deletion.
@@ -2552,7 +2552,7 @@ Async Object Structures
25522552
PyObject *am_aiter(PyObject *self);
25532553

25542554
Must return an :term:`asynchronous iterator` object.
2555-
See :meth:`__anext__` for details.
2555+
See :meth:`~object.__anext__` for details.
25562556

25572557
This slot may be set to ``NULL`` if an object does not implement
25582558
asynchronous iteration protocol.
@@ -2563,7 +2563,8 @@ Async Object Structures
25632563

25642564
PyObject *am_anext(PyObject *self);
25652565

2566-
Must return an :term:`awaitable` object. See :meth:`__anext__` for details.
2566+
Must return an :term:`awaitable` object.
2567+
See :meth:`~object.__anext__` for details.
25672568
This slot may be set to ``NULL``.
25682569

25692570
.. c:member:: sendfunc PyAsyncMethods.am_send

Doc/howto/descriptor.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,8 @@ and if they define :meth:`__set_name__`, that method is called with two
836836
arguments. The *owner* is the class where the descriptor is used, and the
837837
*name* is the class variable the descriptor was assigned to.
838838

839-
The implementation details are in :c:func:`type_new()` and
840-
:c:func:`set_names()` in :source:`Objects/typeobject.c`.
839+
The implementation details are in :c:func:`!type_new` and
840+
:c:func:`!set_names` in :source:`Objects/typeobject.c`.
841841

842842
Since the update logic is in :meth:`type.__new__`, notifications only take
843843
place at the time of class creation. If descriptors are added to the class

Doc/tools/.nitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
Doc/c-api/bool.rst
66
Doc/c-api/buffer.rst
7-
Doc/c-api/capsule.rst
87
Doc/c-api/datetime.rst
98
Doc/c-api/descriptor.rst
109
Doc/c-api/exceptions.rst
@@ -17,7 +16,6 @@ Doc/c-api/intro.rst
1716
Doc/c-api/memory.rst
1817
Doc/c-api/memoryview.rst
1918
Doc/c-api/module.rst
20-
Doc/c-api/none.rst
2119
Doc/c-api/object.rst
2220
Doc/c-api/set.rst
2321
Doc/c-api/stable.rst

0 commit comments

Comments
 (0)