Skip to content

Commit 050933c

Browse files
gh-107298: Fix numerous ref errors and typos in the C API docs
1 parent 58f9c63 commit 050933c

27 files changed

+103
-92
lines changed

Doc/c-api/exceptions.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,21 @@ For convenience, some of these functions will always return a
222222
223223
.. c:function:: PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, const char *filename)
224224
225-
Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, but the
226-
filename is given as a C string. *filename* is decoded from the filesystem
227-
encoding (:func:`os.fsdecode`).
225+
Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior
226+
that if *filename* is not ``NULL``, it is decoded from the filesystem
227+
encoding (:func:`os.fsdecode`) and passed to the constructor of
228+
:exc:`OSError` as a third parameter to be used to define the
229+
:attr:`!filename` attribute of the exception instance.
228230
229231
.. availability:: Windows.
230232
231233
232234
.. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilenameObject(PyObject *type, int ierr, PyObject *filename)
233235
234-
Similar to :c:func:`PyErr_SetFromWindowsErrWithFilenameObject`, with an
235-
additional parameter specifying the exception type to be raised.
236+
Similar to :c:func:`PyErr_SetExcFromWindowsErr`, with the additional behavior
237+
that if *filename* is not ``NULL``, it is passed to the constructor of
238+
:exc:`OSError` as a third parameter to be used to define the
239+
:attr:`!filename` attribute of the exception instance.
236240
237241
.. availability:: Windows.
238242

Doc/c-api/init_config.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ PyWideStringList
8282
If *length* is non-zero, *items* must be non-``NULL`` and all strings must be
8383
non-``NULL``.
8484

85+
.. c:namespace:: NULL
86+
8587
Methods:
8688

8789
.. c:function:: PyStatus PyWideStringList_Append(PyWideStringList *list, const wchar_t *item)
@@ -101,6 +103,8 @@ PyWideStringList
101103
102104
Python must be preinitialized to call this function.
103105
106+
.. c:namespace:: PyWideStringList
107+
104108
Structure fields:
105109
106110
.. c:member:: Py_ssize_t length

Doc/c-api/module.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ The available slot types are:
338338
The *value* pointer of this slot must point to a function of the signature:
339339
340340
.. c:function:: PyObject* create_module(PyObject *spec, PyModuleDef *def)
341+
:noindex:
341342
342343
The function receives a :py:class:`~importlib.machinery.ModuleSpec`
343344
instance, as defined in :PEP:`451`, and the module definition.
@@ -372,6 +373,7 @@ The available slot types are:
372373
The signature of the function is:
373374
374375
.. c:function:: int exec_module(PyObject* module)
376+
:noindex:
375377
376378
If multiple ``Py_mod_exec`` slots are specified, they are processed in the
377379
order they appear in the *m_slots* array.
@@ -380,6 +382,8 @@ The available slot types are:
380382
381383
Specifies one of the following values:
382384
385+
.. c:namespace:: NULL
386+
383387
.. c:macro:: Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED
384388
385389
The module does not support being imported in subinterpreters.

Doc/c-api/unicode.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ the user settings on the machine running the codec.
12921292
12931293
Encode the Unicode object using the specified code page and return a Python
12941294
bytes object. Return ``NULL`` if an exception was raised by the codec. Use
1295-
:c:macro:`CP_ACP` code page to get the MBCS encoder.
1295+
:c:macro:`!CP_ACP` code page to get the MBCS encoder.
12961296
12971297
.. versionadded:: 3.3
12981298

Doc/extending/newtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ have an associated doc string simply by providing the text in the table. An
298298
application can use the introspection API to retrieve the descriptor from the
299299
class object, and get the doc string using its :attr:`__doc__` attribute.
300300

301-
As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry with a :c:member:`~PyMethodDef.name` value
301+
As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry with a :c:member:`~PyMethodDef.ml_name` value
302302
of ``NULL`` is required.
303303

304304
.. XXX Descriptors need to be explained in more detail somewhere, but not here.

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Doc/c-api/structures.rst
2020
Doc/c-api/sys.rst
2121
Doc/c-api/type.rst
2222
Doc/c-api/typeobj.rst
23-
Doc/c-api/unicode.rst
2423
Doc/extending/extending.rst
2524
Doc/extending/newtypes.rst
2625
Doc/glossary.rst

Doc/whatsnew/2.2.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,17 +1078,17 @@ code, none of the changes described here will affect you very much.
10781078

10791079
To upgrade an extension module to the new API, perform the following steps:
10801080

1081-
* Rename :c:func:`Py_TPFLAGS_GC` to :c:func:`PyTPFLAGS_HAVE_GC`.
1081+
* Rename :c:macro:`!Py_TPFLAGS_GC` to :c:macro:`Py_TPFLAGS_HAVE_GC`.
10821082

10831083
* Use :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar` to allocate
10841084
objects, and :c:func:`PyObject_GC_Del` to deallocate them.
10851085

1086-
* Rename :c:func:`PyObject_GC_Init` to :c:func:`PyObject_GC_Track` and
1087-
:c:func:`PyObject_GC_Fini` to :c:func:`PyObject_GC_UnTrack`.
1086+
* Rename :c:func:`!PyObject_GC_Init` to :c:func:`PyObject_GC_Track` and
1087+
:c:func:`!PyObject_GC_Fini` to :c:func:`PyObject_GC_UnTrack`.
10881088

1089-
* Remove :c:func:`PyGC_HEAD_SIZE` from object size calculations.
1089+
* Remove :c:macro:`!PyGC_HEAD_SIZE` from object size calculations.
10901090

1091-
* Remove calls to :c:func:`PyObject_AS_GC` and :c:func:`PyObject_FROM_GC`.
1091+
* Remove calls to :c:func:`!PyObject_AS_GC` and :c:func:`!PyObject_FROM_GC`.
10921092

10931093
* A new ``et`` format sequence was added to :c:func:`PyArg_ParseTuple`; ``et``
10941094
takes both a parameter and an encoding name, and converts the parameter to the
@@ -1219,7 +1219,7 @@ Some of the more notable changes are:
12191219
operator, but these features were rarely used and therefore buggy. The
12201220
:meth:`tolist` method and the :attr:`start`, :attr:`stop`, and :attr:`step`
12211221
attributes are also being deprecated. At the C level, the fourth argument to
1222-
the :c:func:`PyRange_New` function, ``repeat``, has also been deprecated.
1222+
the :c:func:`!PyRange_New` function, ``repeat``, has also been deprecated.
12231223

12241224
* There were a bunch of patches to the dictionary implementation, mostly to fix
12251225
potential core dumps if a dictionary contains objects that sneakily changed

Doc/whatsnew/2.3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,7 @@ Changes to Python's build process and to the C API include:
18971897
but will also mean that you can't get help for Python's built-ins. (Contributed
18981898
by Gustavo Niemeyer.)
18991899

1900-
* The :c:func:`PyArg_NoArgs` macro is now deprecated, and code that uses it
1900+
* The :c:func:`!PyArg_NoArgs` macro is now deprecated, and code that uses it
19011901
should be changed. For Python 2.2 and later, the method definition table can
19021902
specify the :c:macro:`METH_NOARGS` flag, signalling that there are no arguments,
19031903
and the argument checking can then be removed. If compatibility with pre-2.2

Doc/whatsnew/2.4.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ Some of the changes to Python's build process and to the C API are:
14681468
*X* is a NaN. (Contributed by Tim Peters.)
14691469

14701470
* C code can avoid unnecessary locking by using the new
1471-
:c:func:`PyEval_ThreadsInitialized` function to tell if any thread operations
1471+
:c:func:`!PyEval_ThreadsInitialized` function to tell if any thread operations
14721472
have been performed. If this function returns false, no lock operations are
14731473
needed. (Contributed by Nick Coghlan.)
14741474

Doc/whatsnew/2.5.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,9 +2119,9 @@ Changes to Python's build process and to the C API include:
21192119
the various AST nodes in :file:`Parser/Python.asdl`. A Python script reads this
21202120
file and generates a set of C structure definitions in
21212121
:file:`Include/Python-ast.h`. The :c:func:`PyParser_ASTFromString` and
2122-
:c:func:`PyParser_ASTFromFile`, defined in :file:`Include/pythonrun.h`, take
2122+
:c:func:`!PyParser_ASTFromFile`, defined in :file:`Include/pythonrun.h`, take
21232123
Python source as input and return the root of an AST representing the contents.
2124-
This AST can then be turned into a code object by :c:func:`PyAST_Compile`. For
2124+
This AST can then be turned into a code object by :c:func:`!PyAST_Compile`. For
21252125
more information, read the source code, and then ask questions on python-dev.
21262126

21272127
The AST code was developed under Jeremy Hylton's management, and implemented by
@@ -2172,7 +2172,7 @@ Changes to Python's build process and to the C API include:
21722172
``Py_LOCAL(type)`` declares the function as returning a value of the
21732173
specified *type* and uses a fast-calling qualifier.
21742174
``Py_LOCAL_INLINE(type)`` does the same thing and also requests the
2175-
function be inlined. If :c:func:`PY_LOCAL_AGGRESSIVE` is defined before
2175+
function be inlined. If macro :c:macro:`!PY_LOCAL_AGGRESSIVE` is defined before
21762176
:file:`python.h` is included, a set of more aggressive optimizations are enabled
21772177
for the module; you should benchmark the results to find out if these
21782178
optimizations actually make the code faster. (Contributed by Fredrik Lundh at
@@ -2181,7 +2181,7 @@ Changes to Python's build process and to the C API include:
21812181
* ``PyErr_NewException(name, base, dict)`` can now accept a tuple of base
21822182
classes as its *base* argument. (Contributed by Georg Brandl.)
21832183

2184-
* The :c:func:`PyErr_Warn` function for issuing warnings is now deprecated in
2184+
* The :c:func:`!PyErr_Warn` function for issuing warnings is now deprecated in
21852185
favour of ``PyErr_WarnEx(category, message, stacklevel)`` which lets you
21862186
specify the number of stack frames separating this function and the caller. A
21872187
*stacklevel* of 1 is the function calling :c:func:`PyErr_WarnEx`, 2 is the
@@ -2191,7 +2191,7 @@ Changes to Python's build process and to the C API include:
21912191
compiled with a C++ compiler without errors. (Implemented by Anthony Baxter,
21922192
Martin von Löwis, Skip Montanaro.)
21932193

2194-
* The :c:func:`PyRange_New` function was removed. It was never documented, never
2194+
* The :c:func:`!PyRange_New` function was removed. It was never documented, never
21952195
used in the core code, and had dangerously lax error checking. In the unlikely
21962196
case that your extensions were using it, you can replace it by something like
21972197
the following::

0 commit comments

Comments
 (0)