Skip to content

Commit 0ce7be0

Browse files
[3.12] pythongh-115172: Fix explicit index extries for the C API (pythonGH-115173)
(cherry picked from commit 573acb3) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 6e13e50 commit 0ce7be0

14 files changed

+153
-156
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/code.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bound into a function.
4949
.. versionchanged:: 3.11
5050
Added ``qualname`` and ``exceptiontable`` parameters.
5151
52-
.. index:: single: PyCode_New
52+
.. index:: single: PyCode_New (C function)
5353
5454
.. versionchanged:: 3.12
5555
@@ -62,7 +62,7 @@ bound into a function.
6262
Similar to :c:func:`PyUnstable_Code_New`, but with an extra "posonlyargcount" for positional-only arguments.
6363
The same caveats that apply to ``PyUnstable_Code_New`` also apply to this function.
6464
65-
.. index:: single: PyCode_NewWithPosOnlyArgs
65+
.. index:: single: PyCode_NewWithPosOnlyArgs (C function)
6666
6767
.. versionadded:: 3.8 as ``PyCode_NewWithPosOnlyArgs``
6868
@@ -221,7 +221,7 @@ may change without deprecation warnings.
221221
*free* will be called on non-``NULL`` data stored under the new index.
222222
Use :c:func:`Py_DecRef` when storing :c:type:`PyObject`.
223223
224-
.. index:: single: _PyEval_RequestCodeExtraIndex
224+
.. index:: single: _PyEval_RequestCodeExtraIndex (C function)
225225
226226
.. versionadded:: 3.6 as ``_PyEval_RequestCodeExtraIndex``
227227
@@ -239,7 +239,7 @@ may change without deprecation warnings.
239239
If no data was set under the index, set *extra* to ``NULL`` and return
240240
0 without setting an exception.
241241
242-
.. index:: single: _PyCode_GetExtra
242+
.. index:: single: _PyCode_GetExtra (C function)
243243
244244
.. versionadded:: 3.6 as ``_PyCode_GetExtra``
245245
@@ -254,7 +254,7 @@ may change without deprecation warnings.
254254
Set the extra data stored under the given index to *extra*.
255255
Return 0 on success. Set an exception and return -1 on failure.
256256
257-
.. index:: single: _PyCode_SetExtra
257+
.. index:: single: _PyCode_SetExtra (C function)
258258
259259
.. versionadded:: 3.6 as ``_PyCode_SetExtra``
260260

Doc/c-api/exceptions.rst

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ For convenience, some of these functions will always return a
167167
168168
.. c:function:: PyObject* PyErr_SetFromErrno(PyObject *type)
169169
170-
.. index:: single: strerror()
170+
.. index:: single: strerror (C function)
171171
172172
This is a convenience function to raise an exception when a C library function
173173
has returned an error and set the C variable :c:data:`errno`. It constructs a
@@ -622,7 +622,7 @@ Signal Handling
622622
623623
.. index::
624624
pair: module; signal
625-
single: SIGINT
625+
single: SIGINT (C macro)
626626
single: KeyboardInterrupt (built-in exception)
627627
628628
This function interacts with Python's signal handling.
@@ -653,7 +653,7 @@ Signal Handling
653653
654654
.. index::
655655
pair: module; signal
656-
single: SIGINT
656+
single: SIGINT (C macro)
657657
single: KeyboardInterrupt (built-in exception)
658658
659659
Simulate the effect of a :c:macro:`!SIGINT` signal arriving.
@@ -955,59 +955,59 @@ All standard Python exceptions are available as global variables whose names are
955955
the variables:
956956
957957
.. index::
958-
single: PyExc_BaseException
959-
single: PyExc_Exception
960-
single: PyExc_ArithmeticError
961-
single: PyExc_AssertionError
962-
single: PyExc_AttributeError
963-
single: PyExc_BlockingIOError
964-
single: PyExc_BrokenPipeError
965-
single: PyExc_BufferError
966-
single: PyExc_ChildProcessError
967-
single: PyExc_ConnectionAbortedError
968-
single: PyExc_ConnectionError
969-
single: PyExc_ConnectionRefusedError
970-
single: PyExc_ConnectionResetError
971-
single: PyExc_EOFError
972-
single: PyExc_FileExistsError
973-
single: PyExc_FileNotFoundError
974-
single: PyExc_FloatingPointError
975-
single: PyExc_GeneratorExit
976-
single: PyExc_ImportError
977-
single: PyExc_IndentationError
978-
single: PyExc_IndexError
979-
single: PyExc_InterruptedError
980-
single: PyExc_IsADirectoryError
981-
single: PyExc_KeyError
982-
single: PyExc_KeyboardInterrupt
983-
single: PyExc_LookupError
984-
single: PyExc_MemoryError
985-
single: PyExc_ModuleNotFoundError
986-
single: PyExc_NameError
987-
single: PyExc_NotADirectoryError
988-
single: PyExc_NotImplementedError
989-
single: PyExc_OSError
990-
single: PyExc_OverflowError
991-
single: PyExc_PermissionError
992-
single: PyExc_ProcessLookupError
993-
single: PyExc_RecursionError
994-
single: PyExc_ReferenceError
995-
single: PyExc_RuntimeError
996-
single: PyExc_StopAsyncIteration
997-
single: PyExc_StopIteration
998-
single: PyExc_SyntaxError
999-
single: PyExc_SystemError
1000-
single: PyExc_SystemExit
1001-
single: PyExc_TabError
1002-
single: PyExc_TimeoutError
1003-
single: PyExc_TypeError
1004-
single: PyExc_UnboundLocalError
1005-
single: PyExc_UnicodeDecodeError
1006-
single: PyExc_UnicodeEncodeError
1007-
single: PyExc_UnicodeError
1008-
single: PyExc_UnicodeTranslateError
1009-
single: PyExc_ValueError
1010-
single: PyExc_ZeroDivisionError
958+
single: PyExc_BaseException (C var)
959+
single: PyExc_Exception (C var)
960+
single: PyExc_ArithmeticError (C var)
961+
single: PyExc_AssertionError (C var)
962+
single: PyExc_AttributeError (C var)
963+
single: PyExc_BlockingIOError (C var)
964+
single: PyExc_BrokenPipeError (C var)
965+
single: PyExc_BufferError (C var)
966+
single: PyExc_ChildProcessError (C var)
967+
single: PyExc_ConnectionAbortedError (C var)
968+
single: PyExc_ConnectionError (C var)
969+
single: PyExc_ConnectionRefusedError (C var)
970+
single: PyExc_ConnectionResetError (C var)
971+
single: PyExc_EOFError (C var)
972+
single: PyExc_FileExistsError (C var)
973+
single: PyExc_FileNotFoundError (C var)
974+
single: PyExc_FloatingPointError (C var)
975+
single: PyExc_GeneratorExit (C var)
976+
single: PyExc_ImportError (C var)
977+
single: PyExc_IndentationError (C var)
978+
single: PyExc_IndexError (C var)
979+
single: PyExc_InterruptedError (C var)
980+
single: PyExc_IsADirectoryError (C var)
981+
single: PyExc_KeyError (C var)
982+
single: PyExc_KeyboardInterrupt (C var)
983+
single: PyExc_LookupError (C var)
984+
single: PyExc_MemoryError (C var)
985+
single: PyExc_ModuleNotFoundError (C var)
986+
single: PyExc_NameError (C var)
987+
single: PyExc_NotADirectoryError (C var)
988+
single: PyExc_NotImplementedError (C var)
989+
single: PyExc_OSError (C var)
990+
single: PyExc_OverflowError (C var)
991+
single: PyExc_PermissionError (C var)
992+
single: PyExc_ProcessLookupError (C var)
993+
single: PyExc_RecursionError (C var)
994+
single: PyExc_ReferenceError (C var)
995+
single: PyExc_RuntimeError (C var)
996+
single: PyExc_StopAsyncIteration (C var)
997+
single: PyExc_StopIteration (C var)
998+
single: PyExc_SyntaxError (C var)
999+
single: PyExc_SystemError (C var)
1000+
single: PyExc_SystemExit (C var)
1001+
single: PyExc_TabError (C var)
1002+
single: PyExc_TimeoutError (C var)
1003+
single: PyExc_TypeError (C var)
1004+
single: PyExc_UnboundLocalError (C var)
1005+
single: PyExc_UnicodeDecodeError (C var)
1006+
single: PyExc_UnicodeEncodeError (C var)
1007+
single: PyExc_UnicodeError (C var)
1008+
single: PyExc_UnicodeTranslateError (C var)
1009+
single: PyExc_ValueError (C var)
1010+
single: PyExc_ZeroDivisionError (C var)
10111011
10121012
+-----------------------------------------+---------------------------------+----------+
10131013
| C Name | Python Name | Notes |
@@ -1138,9 +1138,9 @@ the variables:
11381138
These are compatibility aliases to :c:data:`PyExc_OSError`:
11391139
11401140
.. index::
1141-
single: PyExc_EnvironmentError
1142-
single: PyExc_IOError
1143-
single: PyExc_WindowsError
1141+
single: PyExc_EnvironmentError (C var)
1142+
single: PyExc_IOError (C var)
1143+
single: PyExc_WindowsError (C var)
11441144
11451145
+-------------------------------------+----------+
11461146
| C Name | Notes |
@@ -1175,17 +1175,17 @@ names are ``PyExc_`` followed by the Python exception name. These have the type
11751175
the variables:
11761176
11771177
.. index::
1178-
single: PyExc_Warning
1179-
single: PyExc_BytesWarning
1180-
single: PyExc_DeprecationWarning
1181-
single: PyExc_FutureWarning
1182-
single: PyExc_ImportWarning
1183-
single: PyExc_PendingDeprecationWarning
1184-
single: PyExc_ResourceWarning
1185-
single: PyExc_RuntimeWarning
1186-
single: PyExc_SyntaxWarning
1187-
single: PyExc_UnicodeWarning
1188-
single: PyExc_UserWarning
1178+
single: PyExc_Warning (C var)
1179+
single: PyExc_BytesWarning (C var)
1180+
single: PyExc_DeprecationWarning (C var)
1181+
single: PyExc_FutureWarning (C var)
1182+
single: PyExc_ImportWarning (C var)
1183+
single: PyExc_PendingDeprecationWarning (C var)
1184+
single: PyExc_ResourceWarning (C var)
1185+
single: PyExc_RuntimeWarning (C var)
1186+
single: PyExc_SyntaxWarning (C var)
1187+
single: PyExc_UnicodeWarning (C var)
1188+
single: PyExc_UserWarning (C var)
11891189
11901190
+------------------------------------------+---------------------------------+----------+
11911191
| C Name | Python Name | Notes |

Doc/c-api/file.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ the :mod:`io` APIs instead.
9595
9696
.. c:function:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)
9797
98-
.. index:: single: Py_PRINT_RAW
98+
.. index:: single: Py_PRINT_RAW (C macro)
9999
100100
Write object *obj* to file object *p*. The only supported flag for *flags* is
101101
: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
@@ -340,9 +340,9 @@ Initializing and finalizing the interpreter
340340
pair: module; __main__
341341
pair: module; sys
342342
triple: module; search; path
343-
single: PySys_SetArgv()
344-
single: PySys_SetArgvEx()
345-
single: Py_FinalizeEx()
343+
single: PySys_SetArgv (C function)
344+
single: PySys_SetArgvEx (C function)
345+
single: Py_FinalizeEx (C function)
346346
347347
Initialize the Python interpreter. In an application embedding Python,
348348
this should be called before using any other Python/C API functions; see
@@ -849,7 +849,7 @@ operations could cause problems in a multi-threaded program: for example, when
849849
two threads simultaneously increment the reference count of the same object, the
850850
reference count could end up being incremented only once instead of twice.
851851
852-
.. index:: single: setswitchinterval() (in module sys)
852+
.. index:: single: setswitchinterval (in module sys)
853853
854854
Therefore, the rule exists that only the thread that has acquired the
855855
:term:`GIL` may operate on Python objects or call Python/C API functions.
@@ -859,8 +859,7 @@ released around potentially blocking I/O operations like reading or writing
859859
a file, so that other Python threads can run in the meantime.
860860
861861
.. index::
862-
single: PyThreadState
863-
single: PyThreadState
862+
single: PyThreadState (C type)
864863
865864
The Python interpreter keeps some thread-specific bookkeeping information
866865
inside a data structure called :c:type:`PyThreadState`. There's also one
@@ -886,8 +885,8 @@ This is so common that a pair of macros exists to simplify it::
886885
Py_END_ALLOW_THREADS
887886
888887
.. index::
889-
single: Py_BEGIN_ALLOW_THREADS
890-
single: Py_END_ALLOW_THREADS
888+
single: Py_BEGIN_ALLOW_THREADS (C macro)
889+
single: Py_END_ALLOW_THREADS (C macro)
891890
892891
The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a
893892
hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the
@@ -902,8 +901,8 @@ The block above expands to the following code::
902901
PyEval_RestoreThread(_save);
903902
904903
.. index::
905-
single: PyEval_RestoreThread()
906-
single: PyEval_SaveThread()
904+
single: PyEval_RestoreThread (C function)
905+
single: PyEval_SaveThread (C function)
907906
908907
Here is how these functions work: the global interpreter lock is used to protect the pointer to the
909908
current thread state. When releasing the lock and saving the thread state,
@@ -1646,8 +1645,8 @@ function. You can create and destroy them using the following functions:
16461645
may be stored internally on the :c:type:`PyInterpreterState`.
16471646
16481647
.. index::
1649-
single: Py_FinalizeEx()
1650-
single: Py_Initialize()
1648+
single: Py_FinalizeEx (C function)
1649+
single: Py_Initialize (C function)
16511650
16521651
Extension modules are shared between (sub-)interpreters as follows:
16531652
@@ -1675,7 +1674,7 @@ function. You can create and destroy them using the following functions:
16751674
As with multi-phase initialization, this means that only C-level static
16761675
and global variables are shared between these modules.
16771676
1678-
.. index:: single: close() (in module os)
1677+
.. index:: single: close (in module os)
16791678
16801679
16811680
.. c:function:: PyThreadState* Py_NewInterpreter(void)
@@ -1698,7 +1697,7 @@ function. You can create and destroy them using the following functions:
16981697
16991698
.. c:function:: void Py_EndInterpreter(PyThreadState *tstate)
17001699
1701-
.. index:: single: Py_FinalizeEx()
1700+
.. index:: single: Py_FinalizeEx (C function)
17021701
17031702
Destroy the (sub-)interpreter represented by the given thread state.
17041703
The given thread state must be the current thread state. See the
@@ -1790,8 +1789,6 @@ pointer and a void pointer argument.
17901789
17911790
.. c:function:: int Py_AddPendingCall(int (*func)(void *), void *arg)
17921791
1793-
.. index:: single: Py_AddPendingCall()
1794-
17951792
Schedule a function to be called from the main interpreter thread. On
17961793
success, ``0`` is returned and *func* is queued for being called in the
17971794
main thread. On failure, ``-1`` is returned without setting any exception.

0 commit comments

Comments
 (0)