Skip to content

Commit b28ba31

Browse files
miss-islingtonZeroIntensityStanFromIreland
authored
[3.13] gh-141004: Document PyFile_OpenCode and PyFile_OpenCodeObject (GH-141413) (GH-141426)
gh-141004: Document `PyFile_OpenCode` and `PyFile_OpenCodeObject` (GH-141413) (cherry picked from commit 2befce8) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Stan Ulbrych <[email protected]>
1 parent 305e9c5 commit b28ba31

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Doc/c-api/file.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,29 @@ the :mod:`io` APIs instead.
9393
.. versionadded:: 3.8
9494
9595
96+
.. c:function:: PyObject *PyFile_OpenCodeObject(PyObject *path)
97+
98+
Open *path* with the mode ``'rb'``. *path* must be a Python :class:`str`
99+
object. The behavior of this function may be overridden by
100+
:c:func:`PyFile_SetOpenCodeHook` to allow for some preprocessing of the
101+
text.
102+
103+
This is analogous to :func:`io.open_code` in Python.
104+
105+
On success, this function returns a :term:`strong reference` to a Python
106+
file object. On failure, this function returns ``NULL`` with an exception
107+
set.
108+
109+
.. versionadded:: 3.8
110+
111+
112+
.. c:function:: PyObject *PyFile_OpenCode(const char *path)
113+
114+
Similar to :c:func:`PyFile_OpenCodeObject`, but *path* is a
115+
UTF-8 encoded :c:expr:`const char*`.
116+
117+
.. versionadded:: 3.8
118+
96119
97120
.. c:function:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)
98121

0 commit comments

Comments
 (0)