From 7a7228c558312da529ad27634ded536c2fc488fc Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 26 Jan 2024 18:49:21 +0300 Subject: [PATCH 1/2] Fix `c-api/file.rst` indexes --- Doc/c-api/file.rst | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Doc/c-api/file.rst b/Doc/c-api/file.rst index 0a03841e467cad..945ceaa1fef469 100644 --- a/Doc/c-api/file.rst +++ b/Doc/c-api/file.rst @@ -60,18 +60,21 @@ the :mod:`io` APIs instead. raised if the end of the file is reached immediately. +.. c:type:: PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *) + + Equivalent of :c:expr:`PyObject *(\*)(PyObject *path, + void *userData)`, where *path* is guaranteed to be + :c:type:`PyUnicodeObject`. + + .. versionadded:: 3.8 + + .. c:function:: int PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction handler) Overrides the normal behavior of :func:`io.open_code` to pass its parameter through the provided handler. - The handler is a function of type: - - .. c:type:: Py_OpenCodeHookFunction - - Equivalent of :c:expr:`PyObject *(\*)(PyObject *path, - void *userData)`, where *path* is guaranteed to be - :c:type:`PyUnicodeObject`. + The *handler* is a function of type :c:type:`Py_OpenCodeHookFunction`. The *userData* pointer is passed into the hook function. Since hook functions may be called from different runtimes, this pointer should not From 09981305336c1b22a24d36fd077996dad8ddd823 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 26 Jan 2024 19:32:40 +0300 Subject: [PATCH 2/2] Restore initial layout --- Doc/c-api/file.rst | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Doc/c-api/file.rst b/Doc/c-api/file.rst index 945ceaa1fef469..d3a78c588454e8 100644 --- a/Doc/c-api/file.rst +++ b/Doc/c-api/file.rst @@ -60,21 +60,19 @@ the :mod:`io` APIs instead. raised if the end of the file is reached immediately. -.. c:type:: PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *) - - Equivalent of :c:expr:`PyObject *(\*)(PyObject *path, - void *userData)`, where *path* is guaranteed to be - :c:type:`PyUnicodeObject`. - - .. versionadded:: 3.8 - - .. c:function:: int PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction handler) Overrides the normal behavior of :func:`io.open_code` to pass its parameter through the provided handler. - The *handler* is a function of type :c:type:`Py_OpenCodeHookFunction`. + The *handler* is a function of type: + + .. c:namespace:: NULL + .. c:type:: PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *) + + Equivalent of :c:expr:`PyObject *(\*)(PyObject *path, + void *userData)`, where *path* is guaranteed to be + :c:type:`PyUnicodeObject`. The *userData* pointer is passed into the hook function. Since hook functions may be called from different runtimes, this pointer should not