Skip to content

Commit d9392c0

Browse files
[3.11] gh-107298: Fix yet more Sphinx warnings in the C API doc (GH-107345) (GH-107381)
(cherry picked from commit 9833052)
1 parent 32e17d4 commit d9392c0

File tree

17 files changed

+327
-75
lines changed

17 files changed

+327
-75
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
@@ -899,7 +909,7 @@ PyConfig
899909
.. c:member:: wchar_t* pythonpath_env
900910
901911
Module search paths (:data:`sys.path`) as a string separated by ``DELIM``
902-
(:data:`os.path.pathsep`).
912+
(:data:`os.pathsep`).
903913
904914
Set by the :envvar:`PYTHONPATH` environment variable.
905915

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
@@ -256,7 +256,7 @@ Object Protocol
256256
257257
Normally only class objects, i.e. instances of :class:`type` or a derived
258258
class, are considered classes. However, objects can override this by having
259-
a :attr:`__bases__` attribute (which must be a tuple of base classes).
259+
a :attr:`~class.__bases__` attribute (which must be a tuple of base classes).
260260
261261
262262
.. c:function:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)
@@ -273,10 +273,10 @@ Object Protocol
273273
is an instance of *cls* if its class is a subclass of *cls*.
274274
275275
An instance *inst* can override what is considered its class by having a
276-
:attr:`__class__` attribute.
276+
:attr:`~instance.__class__` attribute.
277277
278278
An object *cls* can override if it is considered a class, and what its base
279-
classes are, by having a :attr:`__bases__` attribute (which must be a tuple
279+
classes are, by having a :attr:`~class.__bases__` attribute (which must be a tuple
280280
of base classes).
281281
282282

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/typeobj.rst

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ PyObject Slots
483483
--------------
484484

485485
The type object structure extends the :c:type:`PyVarObject` structure. The
486-
:c:member:`~PyVarObject.ob_size` field is used for dynamic types (created by :func:`type_new`,
486+
:c:member:`~PyVarObject.ob_size` field is used for dynamic types (created by :c:func:`!type_new`,
487487
usually called from a class statement). Note that :c:data:`PyType_Type` (the
488488
metatype) initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its instances (i.e.
489489
type objects) *must* have the :c:member:`~PyVarObject.ob_size` field.
@@ -1305,8 +1305,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
13051305
The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage collector to detect
13061306
reference cycles. A typical implementation of a :c:member:`~PyTypeObject.tp_traverse` function
13071307
simply calls :c:func:`Py_VISIT` on each of the instance's members that are Python
1308-
objects that the instance owns. For example, this is function :c:func:`local_traverse` from the
1309-
:mod:`_thread` extension module::
1308+
objects that the instance owns. For example, this is function :c:func:`!local_traverse` from the
1309+
:mod:`!_thread` extension module::
13101310

13111311
static int
13121312
local_traverse(localobject *self, visitproc visit, void *arg)
@@ -1658,7 +1658,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
16581658
called; it may also be initialized to a dictionary containing initial attributes
16591659
for the type. Once :c:func:`PyType_Ready` has initialized the type, extra
16601660
attributes for the type may be added to this dictionary only if they don't
1661-
correspond to overloaded operations (like :meth:`__add__`).
1661+
correspond to overloaded operations (like :meth:`~object.__add__`).
16621662

16631663
**Inheritance:**
16641664

@@ -1759,25 +1759,25 @@ and :c:data:`PyType_Type` effectively act as defaults.)
17591759
**Default:**
17601760

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

17641764

17651765
.. c:member:: initproc PyTypeObject.tp_init
17661766
17671767
An optional pointer to an instance initialization function.
17681768

1769-
This function corresponds to the :meth:`__init__` method of classes. Like
1770-
:meth:`__init__`, it is possible to create an instance without calling
1771-
:meth:`__init__`, and it is possible to reinitialize an instance by calling its
1772-
:meth:`__init__` method again.
1769+
This function corresponds to the :meth:`~object.__init__` method of classes. Like
1770+
:meth:`!__init__`, it is possible to create an instance without calling
1771+
:meth:`!__init__`, and it is possible to reinitialize an instance by calling its
1772+
:meth:`!__init__` method again.
17731773

17741774
The function signature is::
17751775

17761776
int tp_init(PyObject *self, PyObject *args, PyObject *kwds);
17771777

17781778
The self argument is the instance to be initialized; the *args* and *kwds*
17791779
arguments represent positional and keyword arguments of the call to
1780-
:meth:`__init__`.
1780+
:meth:`~object.__init__`.
17811781

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

20562056
**Inheritance:**
20572057

@@ -2243,8 +2243,8 @@ Mapping Object Structures
22432243
.. c:member:: objobjargproc PyMappingMethods.mp_ass_subscript
22442244
22452245
This function is used by :c:func:`PyObject_SetItem`,
2246-
:c:func:`PyObject_DelItem`, :c:func:`PyObject_SetSlice` and
2247-
:c:func:`PyObject_DelSlice`. It has the same signature as
2246+
:c:func:`PyObject_DelItem`, :c:func:`PySequence_SetSlice` and
2247+
:c:func:`PySequence_DelSlice`. It has the same signature as
22482248
:c:func:`!PyObject_SetItem`, but *v* can also be set to ``NULL`` to delete
22492249
an item. If this slot is ``NULL``, the object does not support item
22502250
assignment and deletion.
@@ -2466,7 +2466,7 @@ Async Object Structures
24662466
PyObject *am_aiter(PyObject *self);
24672467

24682468
Must return an :term:`asynchronous iterator` object.
2469-
See :meth:`__anext__` for details.
2469+
See :meth:`~object.__anext__` for details.
24702470

24712471
This slot may be set to ``NULL`` if an object does not implement
24722472
asynchronous iteration protocol.
@@ -2477,7 +2477,8 @@ Async Object Structures
24772477

24782478
PyObject *am_anext(PyObject *self);
24792479

2480-
Must return an :term:`awaitable` object. See :meth:`__anext__` for details.
2480+
Must return an :term:`awaitable` object.
2481+
See :meth:`~object.__anext__` for details.
24812482
This slot may be set to ``NULL``.
24822483

24832484
.. c:member:: sendfunc PyAsyncMethods.am_send

Doc/extending/embedding.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ following two statements before the call to :c:func:`Py_Initialize`::
250250
PyImport_AppendInittab("emb", &PyInit_emb);
251251

252252
These two lines initialize the ``numargs`` variable, and make the
253-
:func:`emb.numargs` function accessible to the embedded Python interpreter.
253+
:func:`!emb.numargs` function accessible to the embedded Python interpreter.
254254
With these extensions, the Python script can do things like
255255

256256
.. code-block:: python

0 commit comments

Comments
 (0)