]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-141004: Document `PyFile_OpenCode` and `PyFile_OpenCodeObject` (GH-141413...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 11 Nov 2025 21:48:29 +0000 (22:48 +0100)
committerGitHub <noreply@github.com>
Tue, 11 Nov 2025 21:48:29 +0000 (16:48 -0500)
gh-141004: Document `PyFile_OpenCode` and `PyFile_OpenCodeObject` (GH-141413)
(cherry picked from commit 2befce86e699fdbb6610949b029bad56a0d0780f)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Doc/c-api/file.rst

index e9019a0d500f7e50c45ce6f502d9c3b5a0a19895..9d01254ddb2a11f06e93b3a799b977309510bdc1 100644 (file)
@@ -93,6 +93,29 @@ the :mod:`io` APIs instead.
    .. versionadded:: 3.8
 
 
+.. c:function:: PyObject *PyFile_OpenCodeObject(PyObject *path)
+
+   Open *path* with the mode ``'rb'``. *path* must be a Python :class:`str`
+   object. The behavior of this function may be overridden by
+   :c:func:`PyFile_SetOpenCodeHook` to allow for some preprocessing of the
+   text.
+
+   This is analogous to :func:`io.open_code` in Python.
+
+   On success, this function returns a :term:`strong reference` to a Python
+   file object. On failure, this function returns ``NULL`` with an exception
+   set.
+
+   .. versionadded:: 3.8
+
+
+.. c:function:: PyObject *PyFile_OpenCode(const char *path)
+
+   Similar to :c:func:`PyFile_OpenCodeObject`, but *path* is a
+   UTF-8 encoded :c:expr:`const char*`.
+
+   .. versionadded:: 3.8
+
 
 .. c:function:: int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)