Skip to content

Commit 446a6db

Browse files
[3.11] gh-115172: Fix explicit index extries for the C API (GH-115173) (GH-115293)
(cherry picked from commit 573acb3)
1 parent 3501eca commit 446a6db

File tree

12 files changed

+126
-129
lines changed

12 files changed

+126
-129
lines changed

Doc/c-api/buffer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ without intermediate copying.
2929
Python provides such a facility at the C level in the form of the :ref:`buffer
3030
protocol <bufferobjects>`. This protocol has two sides:
3131

32-
.. index:: single: PyBufferProcs
32+
.. index:: single: PyBufferProcs (C type)
3333

3434
- on the producer side, a type can export a "buffer interface" which allows
3535
objects of that type to expose information about their underlying buffer.

Doc/c-api/exceptions.rst

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ For convenience, some of these functions will always return a
148148
149149
.. c:function:: PyObject* PyErr_SetFromErrno(PyObject *type)
150150
151-
.. index:: single: strerror()
151+
.. index:: single: strerror (C function)
152152
153153
This is a convenience function to raise an exception when a C library function
154154
has returned an error and set the C variable :c:data:`errno`. It constructs a
@@ -550,7 +550,7 @@ Signal Handling
550550
551551
.. index::
552552
pair: module; signal
553-
single: SIGINT
553+
single: SIGINT (C macro)
554554
single: KeyboardInterrupt (built-in exception)
555555
556556
This function interacts with Python's signal handling.
@@ -581,7 +581,7 @@ Signal Handling
581581
582582
.. index::
583583
pair: module; signal
584-
single: SIGINT
584+
single: SIGINT (C macro)
585585
single: KeyboardInterrupt (built-in exception)
586586
587587
Simulate the effect of a :c:macro:`!SIGINT` signal arriving.
@@ -861,59 +861,59 @@ All standard Python exceptions are available as global variables whose names are
861861
the variables:
862862
863863
.. index::
864-
single: PyExc_BaseException
865-
single: PyExc_Exception
866-
single: PyExc_ArithmeticError
867-
single: PyExc_AssertionError
868-
single: PyExc_AttributeError
869-
single: PyExc_BlockingIOError
870-
single: PyExc_BrokenPipeError
871-
single: PyExc_BufferError
872-
single: PyExc_ChildProcessError
873-
single: PyExc_ConnectionAbortedError
874-
single: PyExc_ConnectionError
875-
single: PyExc_ConnectionRefusedError
876-
single: PyExc_ConnectionResetError
877-
single: PyExc_EOFError
878-
single: PyExc_FileExistsError
879-
single: PyExc_FileNotFoundError
880-
single: PyExc_FloatingPointError
881-
single: PyExc_GeneratorExit
882-
single: PyExc_ImportError
883-
single: PyExc_IndentationError
884-
single: PyExc_IndexError
885-
single: PyExc_InterruptedError
886-
single: PyExc_IsADirectoryError
887-
single: PyExc_KeyError
888-
single: PyExc_KeyboardInterrupt
889-
single: PyExc_LookupError
890-
single: PyExc_MemoryError
891-
single: PyExc_ModuleNotFoundError
892-
single: PyExc_NameError
893-
single: PyExc_NotADirectoryError
894-
single: PyExc_NotImplementedError
895-
single: PyExc_OSError
896-
single: PyExc_OverflowError
897-
single: PyExc_PermissionError
898-
single: PyExc_ProcessLookupError
899-
single: PyExc_RecursionError
900-
single: PyExc_ReferenceError
901-
single: PyExc_RuntimeError
902-
single: PyExc_StopAsyncIteration
903-
single: PyExc_StopIteration
904-
single: PyExc_SyntaxError
905-
single: PyExc_SystemError
906-
single: PyExc_SystemExit
907-
single: PyExc_TabError
908-
single: PyExc_TimeoutError
909-
single: PyExc_TypeError
910-
single: PyExc_UnboundLocalError
911-
single: PyExc_UnicodeDecodeError
912-
single: PyExc_UnicodeEncodeError
913-
single: PyExc_UnicodeError
914-
single: PyExc_UnicodeTranslateError
915-
single: PyExc_ValueError
916-
single: PyExc_ZeroDivisionError
864+
single: PyExc_BaseException (C var)
865+
single: PyExc_Exception (C var)
866+
single: PyExc_ArithmeticError (C var)
867+
single: PyExc_AssertionError (C var)
868+
single: PyExc_AttributeError (C var)
869+
single: PyExc_BlockingIOError (C var)
870+
single: PyExc_BrokenPipeError (C var)
871+
single: PyExc_BufferError (C var)
872+
single: PyExc_ChildProcessError (C var)
873+
single: PyExc_ConnectionAbortedError (C var)
874+
single: PyExc_ConnectionError (C var)
875+
single: PyExc_ConnectionRefusedError (C var)
876+
single: PyExc_ConnectionResetError (C var)
877+
single: PyExc_EOFError (C var)
878+
single: PyExc_FileExistsError (C var)
879+
single: PyExc_FileNotFoundError (C var)
880+
single: PyExc_FloatingPointError (C var)
881+
single: PyExc_GeneratorExit (C var)
882+
single: PyExc_ImportError (C var)
883+
single: PyExc_IndentationError (C var)
884+
single: PyExc_IndexError (C var)
885+
single: PyExc_InterruptedError (C var)
886+
single: PyExc_IsADirectoryError (C var)
887+
single: PyExc_KeyError (C var)
888+
single: PyExc_KeyboardInterrupt (C var)
889+
single: PyExc_LookupError (C var)
890+
single: PyExc_MemoryError (C var)
891+
single: PyExc_ModuleNotFoundError (C var)
892+
single: PyExc_NameError (C var)
893+
single: PyExc_NotADirectoryError (C var)
894+
single: PyExc_NotImplementedError (C var)
895+
single: PyExc_OSError (C var)
896+
single: PyExc_OverflowError (C var)
897+
single: PyExc_PermissionError (C var)
898+
single: PyExc_ProcessLookupError (C var)
899+
single: PyExc_RecursionError (C var)
900+
single: PyExc_ReferenceError (C var)
901+
single: PyExc_RuntimeError (C var)
902+
single: PyExc_StopAsyncIteration (C var)
903+
single: PyExc_StopIteration (C var)
904+
single: PyExc_SyntaxError (C var)
905+
single: PyExc_SystemError (C var)
906+
single: PyExc_SystemExit (C var)
907+
single: PyExc_TabError (C var)
908+
single: PyExc_TimeoutError (C var)
909+
single: PyExc_TypeError (C var)
910+
single: PyExc_UnboundLocalError (C var)
911+
single: PyExc_UnicodeDecodeError (C var)
912+
single: PyExc_UnicodeEncodeError (C var)
913+
single: PyExc_UnicodeError (C var)
914+
single: PyExc_UnicodeTranslateError (C var)
915+
single: PyExc_ValueError (C var)
916+
single: PyExc_ZeroDivisionError (C var)
917917
918918
+-----------------------------------------+---------------------------------+----------+
919919
| C Name | Python Name | Notes |
@@ -1044,9 +1044,9 @@ the variables:
10441044
These are compatibility aliases to :c:data:`PyExc_OSError`:
10451045
10461046
.. index::
1047-
single: PyExc_EnvironmentError
1048-
single: PyExc_IOError
1049-
single: PyExc_WindowsError
1047+
single: PyExc_EnvironmentError (C var)
1048+
single: PyExc_IOError (C var)
1049+
single: PyExc_WindowsError (C var)
10501050
10511051
+-------------------------------------+----------+
10521052
| C Name | Notes |
@@ -1081,17 +1081,17 @@ names are ``PyExc_`` followed by the Python exception name. These have the type
10811081
the variables:
10821082
10831083
.. index::
1084-
single: PyExc_Warning
1085-
single: PyExc_BytesWarning
1086-
single: PyExc_DeprecationWarning
1087-
single: PyExc_FutureWarning
1088-
single: PyExc_ImportWarning
1089-
single: PyExc_PendingDeprecationWarning
1090-
single: PyExc_ResourceWarning
1091-
single: PyExc_RuntimeWarning
1092-
single: PyExc_SyntaxWarning
1093-
single: PyExc_UnicodeWarning
1094-
single: PyExc_UserWarning
1084+
single: PyExc_Warning (C var)
1085+
single: PyExc_BytesWarning (C var)
1086+
single: PyExc_DeprecationWarning (C var)
1087+
single: PyExc_FutureWarning (C var)
1088+
single: PyExc_ImportWarning (C var)
1089+
single: PyExc_PendingDeprecationWarning (C var)
1090+
single: PyExc_ResourceWarning (C var)
1091+
single: PyExc_RuntimeWarning (C var)
1092+
single: PyExc_SyntaxWarning (C var)
1093+
single: PyExc_UnicodeWarning (C var)
1094+
single: PyExc_UserWarning (C var)
10951095
10961096
+------------------------------------------+---------------------------------+----------+
10971097
| C Name | Python Name | Notes |

Doc/c-api/file.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ the :mod:`io` APIs instead.
9696
9797
.. c:function:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)
9898
99-
.. index:: single: Py_PRINT_RAW
99+
.. index:: single: Py_PRINT_RAW (C macro)
100100
101101
Write object *obj* to file object *p*. The only supported flag for *flags* is
102102
:c:macro:`Py_PRINT_RAW`; if given, the :func:`str` of the object is written

Doc/c-api/init.rst

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ Initializing and finalizing the interpreter
237237
pair: module; __main__
238238
pair: module; sys
239239
triple: module; search; path
240-
single: PySys_SetArgv()
241-
single: PySys_SetArgvEx()
242-
single: Py_FinalizeEx()
240+
single: PySys_SetArgv (C function)
241+
single: PySys_SetArgvEx (C function)
242+
single: Py_FinalizeEx (C function)
243243
244244
Initialize the Python interpreter. In an application embedding Python,
245245
this should be called before using any other Python/C API functions; see
@@ -740,7 +740,7 @@ operations could cause problems in a multi-threaded program: for example, when
740740
two threads simultaneously increment the reference count of the same object, the
741741
reference count could end up being incremented only once instead of twice.
742742
743-
.. index:: single: setswitchinterval() (in module sys)
743+
.. index:: single: setswitchinterval (in module sys)
744744
745745
Therefore, the rule exists that only the thread that has acquired the
746746
:term:`GIL` may operate on Python objects or call Python/C API functions.
@@ -750,8 +750,7 @@ released around potentially blocking I/O operations like reading or writing
750750
a file, so that other Python threads can run in the meantime.
751751
752752
.. index::
753-
single: PyThreadState
754-
single: PyThreadState
753+
single: PyThreadState (C type)
755754
756755
The Python interpreter keeps some thread-specific bookkeeping information
757756
inside a data structure called :c:type:`PyThreadState`. There's also one
@@ -777,8 +776,8 @@ This is so common that a pair of macros exists to simplify it::
777776
Py_END_ALLOW_THREADS
778777
779778
.. index::
780-
single: Py_BEGIN_ALLOW_THREADS
781-
single: Py_END_ALLOW_THREADS
779+
single: Py_BEGIN_ALLOW_THREADS (C macro)
780+
single: Py_END_ALLOW_THREADS (C macro)
782781
783782
The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a
784783
hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the
@@ -793,8 +792,8 @@ The block above expands to the following code::
793792
PyEval_RestoreThread(_save);
794793
795794
.. index::
796-
single: PyEval_RestoreThread()
797-
single: PyEval_SaveThread()
795+
single: PyEval_RestoreThread (C function)
796+
single: PyEval_SaveThread (C function)
798797
799798
Here is how these functions work: the global interpreter lock is used to protect the pointer to the
800799
current thread state. When releasing the lock and saving the thread state,
@@ -1417,8 +1416,8 @@ function. You can create and destroy them using the following functions:
14171416
entry.)
14181417
14191418
.. index::
1420-
single: Py_FinalizeEx()
1421-
single: Py_Initialize()
1419+
single: Py_FinalizeEx (C function)
1420+
single: Py_Initialize (C function)
14221421
14231422
Extension modules are shared between (sub-)interpreters as follows:
14241423
@@ -1446,12 +1445,12 @@ function. You can create and destroy them using the following functions:
14461445
As with multi-phase initialization, this means that only C-level static
14471446
and global variables are shared between these modules.
14481447
1449-
.. index:: single: close() (in module os)
1448+
.. index:: single: close (in module os)
14501449
14511450
14521451
.. c:function:: void Py_EndInterpreter(PyThreadState *tstate)
14531452
1454-
.. index:: single: Py_FinalizeEx()
1453+
.. index:: single: Py_FinalizeEx (C function)
14551454
14561455
Destroy the (sub-)interpreter represented by the given thread state. The given
14571456
thread state must be the current thread state. See the discussion of thread
@@ -1501,8 +1500,6 @@ pointer and a void pointer argument.
15011500
15021501
.. c:function:: int Py_AddPendingCall(int (*func)(void *), void *arg)
15031502
1504-
.. index:: single: Py_AddPendingCall()
1505-
15061503
Schedule a function to be called from the main interpreter thread. On
15071504
success, ``0`` is returned and *func* is queued for being called in the
15081505
main thread. On failure, ``-1`` is returned without setting any exception.

Doc/c-api/intro.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ objects that reference each other here; for now, the solution
325325
is "don't do that.")
326326

327327
.. index::
328-
single: Py_INCREF()
329-
single: Py_DECREF()
328+
single: Py_INCREF (C function)
329+
single: Py_DECREF (C function)
330330

331331
Reference counts are always manipulated explicitly. The normal way is
332332
to use the macro :c:func:`Py_INCREF` to take a new reference to an
@@ -401,8 +401,8 @@ function, that function assumes that it now owns that reference, and you are not
401401
responsible for it any longer.
402402

403403
.. index::
404-
single: PyList_SetItem()
405-
single: PyTuple_SetItem()
404+
single: PyList_SetItem (C function)
405+
single: PyTuple_SetItem (C function)
406406

407407
Few functions steal references; the two notable exceptions are
408408
:c:func:`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which steal a reference
@@ -491,8 +491,8 @@ using :c:func:`PySequence_GetItem` (which happens to take exactly the same
491491
arguments), you do own a reference to the returned object.
492492

493493
.. index::
494-
single: PyList_GetItem()
495-
single: PySequence_GetItem()
494+
single: PyList_GetItem (C function)
495+
single: PySequence_GetItem (C function)
496496

497497
Here is an example of how you could write a function that computes the sum of
498498
the items in a list of integers; once using :c:func:`PyList_GetItem`, and once
@@ -587,7 +587,7 @@ caller, then to the caller's caller, and so on, until they reach the top-level
587587
interpreter, where they are reported to the user accompanied by a stack
588588
traceback.
589589

590-
.. index:: single: PyErr_Occurred()
590+
.. index:: single: PyErr_Occurred (C function)
591591

592592
For C programmers, however, error checking always has to be explicit. All
593593
functions in the Python/C API can raise exceptions, unless an explicit claim is
@@ -601,8 +601,8 @@ ambiguous return value, and require explicit testing for errors with
601601
:c:func:`PyErr_Occurred`. These exceptions are always explicitly documented.
602602

603603
.. index::
604-
single: PyErr_SetString()
605-
single: PyErr_Clear()
604+
single: PyErr_SetString (C function)
605+
single: PyErr_Clear (C function)
606606

607607
Exception state is maintained in per-thread storage (this is equivalent to
608608
using global storage in an unthreaded application). A thread can be in one of
@@ -624,7 +624,7 @@ an exception is being passed on between C functions until it reaches the Python
624624
bytecode interpreter's main loop, which takes care of transferring it to
625625
``sys.exc_info()`` and friends.
626626

627-
.. index:: single: exc_info() (in module sys)
627+
.. index:: single: exc_info (in module sys)
628628

629629
Note that starting with Python 1.5, the preferred, thread-safe way to access the
630630
exception state from Python code is to call the function :func:`sys.exc_info`,
@@ -709,9 +709,9 @@ Here is the corresponding C code, in all its glory::
709709
.. index:: single: incr_item()
710710

711711
.. index::
712-
single: PyErr_ExceptionMatches()
713-
single: PyErr_Clear()
714-
single: Py_XDECREF()
712+
single: PyErr_ExceptionMatches (C function)
713+
single: PyErr_Clear (C function)
714+
single: Py_XDECREF (C function)
715715

716716
This example represents an endorsed use of the ``goto`` statement in C!
717717
It illustrates the use of :c:func:`PyErr_ExceptionMatches` and
@@ -735,7 +735,7 @@ the finalization, of the Python interpreter. Most functionality of the
735735
interpreter can only be used after the interpreter has been initialized.
736736

737737
.. index::
738-
single: Py_Initialize()
738+
single: Py_Initialize (C function)
739739
pair: module; builtins
740740
pair: module; __main__
741741
pair: module; sys
@@ -770,11 +770,11 @@ environment variable :envvar:`PYTHONHOME`, or insert additional directories in
770770
front of the standard path by setting :envvar:`PYTHONPATH`.
771771

772772
.. index::
773-
single: Py_SetProgramName()
774-
single: Py_GetPath()
775-
single: Py_GetPrefix()
776-
single: Py_GetExecPrefix()
777-
single: Py_GetProgramFullPath()
773+
single: Py_SetProgramName (C function)
774+
single: Py_GetPath (C function)
775+
single: Py_GetPrefix (C function)
776+
single: Py_GetExecPrefix (C function)
777+
single: Py_GetProgramFullPath (C function)
778778

779779
The embedding application can steer the search by calling
780780
``Py_SetProgramName(file)`` *before* calling :c:func:`Py_Initialize`. Note that
@@ -784,7 +784,7 @@ control has to provide its own implementation of :c:func:`Py_GetPath`,
784784
:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and
785785
:c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`).
786786

787-
.. index:: single: Py_IsInitialized()
787+
.. index:: single: Py_IsInitialized (C function)
788788

789789
Sometimes, it is desirable to "uninitialize" Python. For instance, the
790790
application may want to start over (make another call to

0 commit comments

Comments
 (0)