Skip to content

Commit eec26ea

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

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
@@ -1271,8 +1271,8 @@ as internal buffering of data.
12711271

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

12771277
.. versionchanged:: 3.3
12781278
Added the *dir_fd* parameter.
@@ -1626,7 +1626,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
16261626
descriptor as returned by :func:`os.open` or :func:`pipe`. To read a
16271627
"file object" returned by the built-in function :func:`open` or by
16281628
:func:`popen` or :func:`fdopen`, or :data:`sys.stdin`, use its
1629-
:meth:`~file.read` or :meth:`~file.readline` methods.
1629+
:meth:`~io.TextIOBase.read` or :meth:`~io.IOBase.readline` methods.
16301630

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

18201820
.. versionchanged:: 3.5
18211821
If the system call is interrupted and the signal handler does not raise an
@@ -4253,7 +4253,7 @@ to be ignored.
42534253
The current process is replaced immediately. Open file objects and
42544254
descriptors are not flushed, so if there may be data buffered
42554255
on these open files, you should flush them using
4256-
:func:`sys.stdout.flush` or :func:`os.fsync` before calling an
4256+
:func:`~io.IOBase.flush` or :func:`os.fsync` before calling an
42574257
:func:`exec\* <execl>` function.
42584258

42594259
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
@@ -1348,12 +1348,28 @@ also :func:`os.popen`, :func:`os.fdopen`, and the
13481348
:meth:`~socket.socket.makefile` method of socket objects (and perhaps by
13491349
other functions or methods provided by extension modules).
13501350

1351+
File objects implement common methods, listed below, to simplify usage in
1352+
generic code. They are expected to be :ref:`context-managers`.
1353+
13511354
The objects ``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` are
13521355
initialized to file objects corresponding to the interpreter's standard
13531356
input, output and error streams; they are all open in text mode and
13541357
therefore follow the interface defined by the :class:`io.TextIOBase`
13551358
abstract class.
13561359

1360+
.. method:: file.read(size=-1, /)
1361+
1362+
Retrieve up to *size* data from the file. As a convenience if *size* is
1363+
unspecified or -1 retrieve all data available.
1364+
1365+
.. method:: file.write(data, /)
1366+
1367+
Store *data* to the file.
1368+
1369+
.. method:: file.close()
1370+
1371+
Flush any buffers and close the underlying file.
1372+
13571373

13581374
Internal types
13591375
--------------

0 commit comments

Comments
 (0)