@@ -60,6 +60,31 @@ the :mod:`io` APIs instead.
6060 raised if the end of the file is reached immediately.
6161
6262
63+ .. c :function :: char * Py_UniversalNewlineFgets (char *buf, int n, FILE *stream, PyObject *fobj)
64+
65+ Read a line from the C stream *stream * into the buffer *buf *, like the
66+ C standard library function :c:func: `!fgets `, but treating all of ``\n ``,
67+ ``\r `` and ``\r\n `` as line endings (see :term: `universal newlines `).
68+ Any ``\r`` or ``\r\n`` read from the stream is stored in *buf* as a
69+ single ``\n``.
70+
71+ At most ``n - 1`` characters are stored in *buf*; reading stops after a
72+ newline has been stored or when the end of the file is reached.
73+ The result is always null-terminated.
74+ *stream * should be opened in binary mode, so that the C library does not
75+ perform its own newline translation.
76+
77+ Return *buf * on success.
78+ Return ``NULL `` if no characters could be read, because *stream * is at
79+ end of file, a read error occurred, or *n * is less than 2.
80+ Like :c:func: `!fgets `, this function does not distinguish between end of
81+ file and a read error, and it does not set an exception.
82+
83+ *fobj * exists only for backward compatibility and must be ``NULL ``.
84+ If it is not ``NULL ``, nothing is read, :c:data: `errno ` is set to
85+ :c:macro: `!ENXIO ` and ``NULL `` is returned.
86+
87+
6388.. c :function :: int PyFile_SetOpenCodeHook (Py_OpenCodeHookFunction handler)
6489
6590 Overrides the normal behavior of :func:`io.open_code` to pass its parameter
0 commit comments