From 46e1fa672d770656afb71c01c80a0ed55a6982b9 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 25 Jan 2024 10:28:59 +0300 Subject: [PATCH 1/3] gh-101100: Fix sphinx warnings in `c-api/file.rst` --- Doc/c-api/file.rst | 8 ++++++-- Doc/c-api/object.rst | 7 +++++++ Doc/tools/.nitignore | 1 - 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Doc/c-api/file.rst b/Doc/c-api/file.rst index b36c800e00444a..b5b8547ae14cbe 100644 --- a/Doc/c-api/file.rst +++ b/Doc/c-api/file.rst @@ -65,8 +65,12 @@ the :mod:`io` APIs instead. 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: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 + + 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 diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst index 8a179690d048e3..9b6f2a6ca4bd7e 100644 --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -19,6 +19,13 @@ Object Protocol to NotImplemented and return it). +.. c:macro:: Py_PRINT_RAW + + Flag to be used with multiple functions that print the object (like :c:func:`PyObject_Print` and :c:func:`PyFile_WriteObject`). + If passed, these function would use the :func:`str` of the object + instead of the :func:`repr`. + + .. c:function:: int PyObject_Print(PyObject *o, FILE *fp, int flags) Print an object *o*, on file *fp*. Returns ``-1`` on error. The flags argument diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 00b4b6919ff14a..112d56c25588e8 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -4,7 +4,6 @@ Doc/c-api/descriptor.rst Doc/c-api/exceptions.rst -Doc/c-api/file.rst Doc/c-api/float.rst Doc/c-api/gcsupport.rst Doc/c-api/init.rst From 82d963344c9223e672e5063695106f5128bc1475 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 25 Jan 2024 10:36:14 +0300 Subject: [PATCH 2/3] Remove `c-api/object.rst` --- Doc/tools/.nitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 112d56c25588e8..d56a44ad09a6f8 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -11,7 +11,6 @@ Doc/c-api/init_config.rst Doc/c-api/intro.rst Doc/c-api/memoryview.rst Doc/c-api/module.rst -Doc/c-api/object.rst Doc/c-api/stable.rst Doc/c-api/sys.rst Doc/c-api/type.rst From 053089096fa89c565c051f5cecacbfb5d7998653 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Thu, 25 Jan 2024 11:58:42 +0300 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/c-api/file.rst | 3 ++- Doc/c-api/object.rst | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/file.rst b/Doc/c-api/file.rst index b5b8547ae14cbe..0a03841e467cad 100644 --- a/Doc/c-api/file.rst +++ b/Doc/c-api/file.rst @@ -70,7 +70,8 @@ the :mod:`io` APIs instead. .. c:type:: Py_OpenCodeHookFunction Equivalent of :c:expr:`PyObject *(\*)(PyObject *path, - void *userData)`, where *path* is guaranteed to be :c:type:`PyUnicodeObject`. + 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 diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst index 9b6f2a6ca4bd7e..4f656779c80b1a 100644 --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -21,7 +21,8 @@ Object Protocol .. c:macro:: Py_PRINT_RAW - Flag to be used with multiple functions that print the object (like :c:func:`PyObject_Print` and :c:func:`PyFile_WriteObject`). + Flag to be used with multiple functions that print the object (like + :c:func:`PyObject_Print` and :c:func:`PyFile_WriteObject`). If passed, these function would use the :func:`str` of the object instead of the :func:`repr`.