Skip to content

Commit a52e949

Browse files
committed
Document PyFile_OpenCode() and PyFile_OpenCodeObject().
1 parent 7211a34 commit a52e949

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Doc/c-api/file.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,30 @@ the :mod:`io` APIs instead.
9393
.. versionadded:: 3.8
9494
9595
96+
.. c:function:: PyObject *PyFile_OpenCodeObject(PyObject *path)
97+
98+
Open *path* and read the text. *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+
:c:expr:`const char*` that is decoded by the
116+
:term:`filesystem encoding and error handler`.
117+
118+
.. versionadded:: 3.8
119+
96120
97121
.. c:function:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)
98122
@@ -108,3 +132,4 @@ the :mod:`io` APIs instead.
108132
109133
Write string *s* to file object *p*. Return ``0`` on success or ``-1`` on
110134
failure; the appropriate exception will be set.
135+

0 commit comments

Comments
 (0)