Skip to content

Commit f4d5332

Browse files
miss-islingtoncmaloneywillingc
authored
[3.14] gh-101100: Fix sphinx reference warnings around I/O (GH-139592) (#145794)
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
1 parent e765696 commit f4d5332

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

Doc/library/email.parser.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ message body, instead setting the payload to the raw body.
155155

156156
Read all the data from the binary file-like object *fp*, parse the
157157
resulting bytes, and return the message object. *fp* must support
158-
both the :meth:`~io.IOBase.readline` and the :meth:`~io.IOBase.read`
158+
both the :meth:`~io.IOBase.readline` and the :meth:`~io.BufferedIOBase.read`
159159
methods.
160160

161161
The bytes contained in *fp* must be formatted as a block of :rfc:`5322`

Doc/library/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ The following exceptions are the exceptions that are usually raised.
221221
.. exception:: EOFError
222222

223223
Raised when the :func:`input` function hits an end-of-file condition (EOF)
224-
without reading any data. (Note: the :meth:`!io.IOBase.read` and
224+
without reading any data. (Note: the :meth:`io.TextIOBase.read` and
225225
:meth:`io.IOBase.readline` methods return an empty string when they hit EOF.)
226226

227227

Doc/library/os.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,8 +1297,8 @@ as internal buffering of data.
12971297

12981298
This function is intended for low-level I/O. For normal usage, use the
12991299
built-in function :func:`open`, which returns a :term:`file object` with
1300-
:meth:`~file.read` and :meth:`~file.write` methods (and many more). To
1301-
wrap a file descriptor in a file object, use :func:`fdopen`.
1300+
:meth:`~io.BufferedIOBase.read` and :meth:`~io.BufferedIOBase.write` methods.
1301+
To wrap a file descriptor in a file object, use :func:`fdopen`.
13021302

13031303
.. versionchanged:: 3.3
13041304
Added the *dir_fd* parameter.
@@ -1652,7 +1652,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
16521652
descriptor as returned by :func:`os.open` or :func:`pipe`. To read a
16531653
"file object" returned by the built-in function :func:`open` or by
16541654
:func:`popen` or :func:`fdopen`, or :data:`sys.stdin`, use its
1655-
:meth:`~file.read` or :meth:`~file.readline` methods.
1655+
:meth:`~io.TextIOBase.read` or :meth:`~io.IOBase.readline` methods.
16561656

16571657
.. versionchanged:: 3.5
16581658
If the system call is interrupted and the signal handler does not raise an
@@ -1887,7 +1887,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
18871887
descriptor as returned by :func:`os.open` or :func:`pipe`. To write a "file
18881888
object" returned by the built-in function :func:`open` or by :func:`popen` or
18891889
:func:`fdopen`, or :data:`sys.stdout` or :data:`sys.stderr`, use its
1890-
:meth:`~file.write` method.
1890+
:meth:`~io.TextIOBase.write` method.
18911891

18921892
.. versionchanged:: 3.5
18931893
If the system call is interrupted and the signal handler does not raise an
@@ -4326,7 +4326,7 @@ to be ignored.
43264326
The current process is replaced immediately. Open file objects and
43274327
descriptors are not flushed, so if there may be data buffered
43284328
on these open files, you should flush them using
4329-
:func:`sys.stdout.flush` or :func:`os.fsync` before calling an
4329+
:func:`~io.IOBase.flush` or :func:`os.fsync` before calling an
43304330
:func:`exec\* <execl>` function.
43314331

43324332
The "l" and "v" variants of the :func:`exec\* <execl>` functions differ in how

Doc/reference/datamodel.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,12 +1417,28 @@ also :func:`os.popen`, :func:`os.fdopen`, and the
14171417
:meth:`~socket.socket.makefile` method of socket objects (and perhaps by
14181418
other functions or methods provided by extension modules).
14191419

1420+
File objects implement common methods, listed below, to simplify usage in
1421+
generic code. They are expected to be :ref:`context-managers`.
1422+
14201423
The objects ``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` are
14211424
initialized to file objects corresponding to the interpreter's standard
14221425
input, output and error streams; they are all open in text mode and
14231426
therefore follow the interface defined by the :class:`io.TextIOBase`
14241427
abstract class.
14251428

1429+
.. method:: file.read(size=-1, /)
1430+
1431+
Retrieve up to *size* data from the file. As a convenience if *size* is
1432+
unspecified or -1 retrieve all data available.
1433+
1434+
.. method:: file.write(data, /)
1435+
1436+
Store *data* to the file.
1437+
1438+
.. method:: file.close()
1439+
1440+
Flush any buffers and close the underlying file.
1441+
14261442

14271443
Internal types
14281444
--------------

0 commit comments

Comments
 (0)