Skip to content

gh-115172: Fix explicit index extries for the C API #115173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/c-api/buffer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ without intermediate copying.
Python provides such a facility at the C level in the form of the :ref:`buffer
protocol <bufferobjects>`. This protocol has two sides:

.. index:: single: PyBufferProcs
.. index:: single: PyBufferProcs (C type)

- on the producer side, a type can export a "buffer interface" which allows
objects of that type to expose information about their underlying buffer.
Expand Down
10 changes: 5 additions & 5 deletions Doc/c-api/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bound into a function.
.. versionchanged:: 3.11
Added ``qualname`` and ``exceptiontable`` parameters.

.. index:: single: PyCode_New
.. index:: single: PyCode_New (C function)

.. versionchanged:: 3.12

Expand All @@ -61,7 +61,7 @@ bound into a function.
Similar to :c:func:`PyUnstable_Code_New`, but with an extra "posonlyargcount" for positional-only arguments.
The same caveats that apply to ``PyUnstable_Code_New`` also apply to this function.

.. index:: single: PyCode_NewWithPosOnlyArgs
.. index:: single: PyCode_NewWithPosOnlyArgs (C function)

.. versionadded:: 3.8 as ``PyCode_NewWithPosOnlyArgs``

Expand Down Expand Up @@ -220,7 +220,7 @@ may change without deprecation warnings.
*free* will be called on non-``NULL`` data stored under the new index.
Use :c:func:`Py_DecRef` when storing :c:type:`PyObject`.

.. index:: single: _PyEval_RequestCodeExtraIndex
.. index:: single: _PyEval_RequestCodeExtraIndex (C function)

.. versionadded:: 3.6 as ``_PyEval_RequestCodeExtraIndex``

Expand All @@ -238,7 +238,7 @@ may change without deprecation warnings.
If no data was set under the index, set *extra* to ``NULL`` and return
0 without setting an exception.

.. index:: single: _PyCode_GetExtra
.. index:: single: _PyCode_GetExtra (C function)

.. versionadded:: 3.6 as ``_PyCode_GetExtra``

Expand All @@ -253,7 +253,7 @@ may change without deprecation warnings.
Set the extra data stored under the given index to *extra*.
Return 0 on success. Set an exception and return -1 on failure.

.. index:: single: _PyCode_SetExtra
.. index:: single: _PyCode_SetExtra (C function)

.. versionadded:: 3.6 as ``_PyCode_SetExtra``

Expand Down
140 changes: 70 additions & 70 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ For convenience, some of these functions will always return a

.. c:function:: PyObject* PyErr_SetFromErrno(PyObject *type)

.. index:: single: strerror()
.. index:: single: strerror (C function)

This is a convenience function to raise an exception when a C library function
has returned an error and set the C variable :c:data:`errno`. It constructs a
Expand Down Expand Up @@ -635,7 +635,7 @@ Signal Handling

.. index::
pair: module; signal
single: SIGINT
single: SIGINT (C macro)
single: KeyboardInterrupt (built-in exception)

This function interacts with Python's signal handling.
Expand Down Expand Up @@ -666,7 +666,7 @@ Signal Handling

.. index::
pair: module; signal
single: SIGINT
single: SIGINT (C macro)
single: KeyboardInterrupt (built-in exception)

Simulate the effect of a :c:macro:`!SIGINT` signal arriving.
Expand Down Expand Up @@ -968,59 +968,59 @@ All standard Python exceptions are available as global variables whose names are
the variables:

.. index::
single: PyExc_BaseException
single: PyExc_Exception
single: PyExc_ArithmeticError
single: PyExc_AssertionError
single: PyExc_AttributeError
single: PyExc_BlockingIOError
single: PyExc_BrokenPipeError
single: PyExc_BufferError
single: PyExc_ChildProcessError
single: PyExc_ConnectionAbortedError
single: PyExc_ConnectionError
single: PyExc_ConnectionRefusedError
single: PyExc_ConnectionResetError
single: PyExc_EOFError
single: PyExc_FileExistsError
single: PyExc_FileNotFoundError
single: PyExc_FloatingPointError
single: PyExc_GeneratorExit
single: PyExc_ImportError
single: PyExc_IndentationError
single: PyExc_IndexError
single: PyExc_InterruptedError
single: PyExc_IsADirectoryError
single: PyExc_KeyError
single: PyExc_KeyboardInterrupt
single: PyExc_LookupError
single: PyExc_MemoryError
single: PyExc_ModuleNotFoundError
single: PyExc_NameError
single: PyExc_NotADirectoryError
single: PyExc_NotImplementedError
single: PyExc_OSError
single: PyExc_OverflowError
single: PyExc_PermissionError
single: PyExc_ProcessLookupError
single: PyExc_RecursionError
single: PyExc_ReferenceError
single: PyExc_RuntimeError
single: PyExc_StopAsyncIteration
single: PyExc_StopIteration
single: PyExc_SyntaxError
single: PyExc_SystemError
single: PyExc_SystemExit
single: PyExc_TabError
single: PyExc_TimeoutError
single: PyExc_TypeError
single: PyExc_UnboundLocalError
single: PyExc_UnicodeDecodeError
single: PyExc_UnicodeEncodeError
single: PyExc_UnicodeError
single: PyExc_UnicodeTranslateError
single: PyExc_ValueError
single: PyExc_ZeroDivisionError
single: PyExc_BaseException (C var)
single: PyExc_Exception (C var)
single: PyExc_ArithmeticError (C var)
single: PyExc_AssertionError (C var)
single: PyExc_AttributeError (C var)
single: PyExc_BlockingIOError (C var)
single: PyExc_BrokenPipeError (C var)
single: PyExc_BufferError (C var)
single: PyExc_ChildProcessError (C var)
single: PyExc_ConnectionAbortedError (C var)
single: PyExc_ConnectionError (C var)
single: PyExc_ConnectionRefusedError (C var)
single: PyExc_ConnectionResetError (C var)
single: PyExc_EOFError (C var)
single: PyExc_FileExistsError (C var)
single: PyExc_FileNotFoundError (C var)
single: PyExc_FloatingPointError (C var)
single: PyExc_GeneratorExit (C var)
single: PyExc_ImportError (C var)
single: PyExc_IndentationError (C var)
single: PyExc_IndexError (C var)
single: PyExc_InterruptedError (C var)
single: PyExc_IsADirectoryError (C var)
single: PyExc_KeyError (C var)
single: PyExc_KeyboardInterrupt (C var)
single: PyExc_LookupError (C var)
single: PyExc_MemoryError (C var)
single: PyExc_ModuleNotFoundError (C var)
single: PyExc_NameError (C var)
single: PyExc_NotADirectoryError (C var)
single: PyExc_NotImplementedError (C var)
single: PyExc_OSError (C var)
single: PyExc_OverflowError (C var)
single: PyExc_PermissionError (C var)
single: PyExc_ProcessLookupError (C var)
single: PyExc_RecursionError (C var)
single: PyExc_ReferenceError (C var)
single: PyExc_RuntimeError (C var)
single: PyExc_StopAsyncIteration (C var)
single: PyExc_StopIteration (C var)
single: PyExc_SyntaxError (C var)
single: PyExc_SystemError (C var)
single: PyExc_SystemExit (C var)
single: PyExc_TabError (C var)
single: PyExc_TimeoutError (C var)
single: PyExc_TypeError (C var)
single: PyExc_UnboundLocalError (C var)
single: PyExc_UnicodeDecodeError (C var)
single: PyExc_UnicodeEncodeError (C var)
single: PyExc_UnicodeError (C var)
single: PyExc_UnicodeTranslateError (C var)
single: PyExc_ValueError (C var)
single: PyExc_ZeroDivisionError (C var)

+-----------------------------------------+---------------------------------+----------+
| C Name | Python Name | Notes |
Expand Down Expand Up @@ -1151,9 +1151,9 @@ the variables:
These are compatibility aliases to :c:data:`PyExc_OSError`:

.. index::
single: PyExc_EnvironmentError
single: PyExc_IOError
single: PyExc_WindowsError
single: PyExc_EnvironmentError (C var)
single: PyExc_IOError (C var)
single: PyExc_WindowsError (C var)

+-------------------------------------+----------+
| C Name | Notes |
Expand Down Expand Up @@ -1188,17 +1188,17 @@ names are ``PyExc_`` followed by the Python exception name. These have the type
the variables:

.. index::
single: PyExc_Warning
single: PyExc_BytesWarning
single: PyExc_DeprecationWarning
single: PyExc_FutureWarning
single: PyExc_ImportWarning
single: PyExc_PendingDeprecationWarning
single: PyExc_ResourceWarning
single: PyExc_RuntimeWarning
single: PyExc_SyntaxWarning
single: PyExc_UnicodeWarning
single: PyExc_UserWarning
single: PyExc_Warning (C var)
single: PyExc_BytesWarning (C var)
single: PyExc_DeprecationWarning (C var)
single: PyExc_FutureWarning (C var)
single: PyExc_ImportWarning (C var)
single: PyExc_PendingDeprecationWarning (C var)
single: PyExc_ResourceWarning (C var)
single: PyExc_RuntimeWarning (C var)
single: PyExc_SyntaxWarning (C var)
single: PyExc_UnicodeWarning (C var)
single: PyExc_UserWarning (C var)

+------------------------------------------+---------------------------------+----------+
| C Name | Python Name | Notes |
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ the :mod:`io` APIs instead.

.. c:function:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)

.. index:: single: Py_PRINT_RAW
.. index:: single: Py_PRINT_RAW (C macro)

Write object *obj* to file object *p*. The only supported flag for *flags* is
:c:macro:`Py_PRINT_RAW`; if given, the :func:`str` of the object is written
Expand Down
25 changes: 11 additions & 14 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ Initializing and finalizing the interpreter
pair: module; __main__
pair: module; sys
triple: module; search; path
single: Py_FinalizeEx()
single: Py_FinalizeEx (C function)

Initialize the Python interpreter. In an application embedding Python,
this should be called before using any other Python/C API functions; see
Expand Down Expand Up @@ -661,7 +661,7 @@ operations could cause problems in a multi-threaded program: for example, when
two threads simultaneously increment the reference count of the same object, the
reference count could end up being incremented only once instead of twice.

.. index:: single: setswitchinterval() (in module sys)
.. index:: single: setswitchinterval (in module sys)

Therefore, the rule exists that only the thread that has acquired the
:term:`GIL` may operate on Python objects or call Python/C API functions.
Expand All @@ -671,8 +671,7 @@ released around potentially blocking I/O operations like reading or writing
a file, so that other Python threads can run in the meantime.

.. index::
single: PyThreadState
single: PyThreadState
single: PyThreadState (C type)

The Python interpreter keeps some thread-specific bookkeeping information
inside a data structure called :c:type:`PyThreadState`. There's also one
Expand All @@ -698,8 +697,8 @@ This is so common that a pair of macros exists to simplify it::
Py_END_ALLOW_THREADS

.. index::
single: Py_BEGIN_ALLOW_THREADS
single: Py_END_ALLOW_THREADS
single: Py_BEGIN_ALLOW_THREADS (C macro)
single: Py_END_ALLOW_THREADS (C macro)

The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a
hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the
Expand All @@ -714,8 +713,8 @@ The block above expands to the following code::
PyEval_RestoreThread(_save);

.. index::
single: PyEval_RestoreThread()
single: PyEval_SaveThread()
single: PyEval_RestoreThread (C function)
single: PyEval_SaveThread (C function)

Here is how these functions work: the global interpreter lock is used to protect the pointer to the
current thread state. When releasing the lock and saving the thread state,
Expand Down Expand Up @@ -1399,8 +1398,8 @@ function. You can create and destroy them using the following functions:
may be stored internally on the :c:type:`PyInterpreterState`.

.. index::
single: Py_FinalizeEx()
single: Py_Initialize()
single: Py_FinalizeEx (C function)
single: Py_Initialize (C function)

Extension modules are shared between (sub-)interpreters as follows:

Expand Down Expand Up @@ -1428,7 +1427,7 @@ function. You can create and destroy them using the following functions:
As with multi-phase initialization, this means that only C-level static
and global variables are shared between these modules.

.. index:: single: close() (in module os)
.. index:: single: close (in module os)


.. c:function:: PyThreadState* Py_NewInterpreter(void)
Expand All @@ -1451,7 +1450,7 @@ function. You can create and destroy them using the following functions:

.. c:function:: void Py_EndInterpreter(PyThreadState *tstate)

.. index:: single: Py_FinalizeEx()
.. index:: single: Py_FinalizeEx (C function)

Destroy the (sub-)interpreter represented by the given thread state.
The given thread state must be the current thread state. See the
Expand Down Expand Up @@ -1543,8 +1542,6 @@ pointer and a void pointer argument.

.. c:function:: int Py_AddPendingCall(int (*func)(void *), void *arg)

.. index:: single: Py_AddPendingCall()

Schedule a function to be called from the main interpreter thread. On
success, ``0`` is returned and *func* is queued for being called in the
main thread. On failure, ``-1`` is returned without setting any exception.
Expand Down
Loading