Skip to content

Commit cf7c67b

Browse files
cmaloneywillingc
andauthored
gh-101100: Fix sphinx reference warnings around I/O (#139592)
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
1 parent c3955e0 commit cf7c67b

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

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

13001300
.. versionchanged:: 3.3
13011301
Added the *dir_fd* parameter.
@@ -1670,7 +1670,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
16701670
descriptor as returned by :func:`os.open` or :func:`pipe`. To read a
16711671
"file object" returned by the built-in function :func:`open` or by
16721672
:func:`popen` or :func:`fdopen`, or :data:`sys.stdin`, use its
1673-
:meth:`~file.read` or :meth:`~file.readline` methods.
1673+
:meth:`~io.TextIOBase.read` or :meth:`~io.IOBase.readline` methods.
16741674

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

19101910
.. versionchanged:: 3.5
19111911
If the system call is interrupted and the signal handler does not raise an
@@ -4720,7 +4720,7 @@ to be ignored.
47204720
The current process is replaced immediately. Open file objects and
47214721
descriptors are not flushed, so if there may be data buffered
47224722
on these open files, you should flush them using
4723-
:func:`sys.stdout.flush` or :func:`os.fsync` before calling an
4723+
:func:`~io.IOBase.flush` or :func:`os.fsync` before calling an
47244724
:func:`exec\* <execl>` function.
47254725

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

1404+
File objects implement common methods, listed below, to simplify usage in
1405+
generic code. They are expected to be :ref:`context-managers`.
1406+
14041407
The objects ``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` are
14051408
initialized to file objects corresponding to the interpreter's standard
14061409
input, output and error streams; they are all open in text mode and
14071410
therefore follow the interface defined by the :class:`io.TextIOBase`
14081411
abstract class.
14091412

1413+
.. method:: file.read(size=-1, /)
1414+
1415+
Retrieve up to *size* data from the file. As a convenience if *size* is
1416+
unspecified or -1 retrieve all data available.
1417+
1418+
.. method:: file.write(data, /)
1419+
1420+
Store *data* to the file.
1421+
1422+
.. method:: file.close()
1423+
1424+
Flush any buffers and close the underlying file.
1425+
14101426

14111427
Internal types
14121428
--------------

0 commit comments

Comments
 (0)