Skip to content

Commit 2ff7393

Browse files
committed
gh-101100: Fix sphinx warnings around I/O
Resolves 7 warnings. Generally: "file object" -> IOBase; "binary"/`byte` read/write -> BufferedIOBase, "text"/`str` read/write -> TextIOBase Specific cases: - `EOFError` is for `input` builtin function which reads a `str`, so `TextIOBase` - `os.read` and `os.write` speak bytes but the sentence is about `sys.stdin` and `sys.stdout` which are `TextIOBase`; use the function that gets called by `sys.stdout.write`. - `os.exec`: `flush` is talking about files generally, so `IOBase` - `email.parser` is talking about binary files / `bytes` so `BufferedIOBase`
1 parent 9964320 commit 2ff7393

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-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 (and many
1298+
more). To wrap a file descriptor in a file object, use :func:`fdopen`.
12991299

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

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

19001900
.. versionchanged:: 3.5
19011901
If the system call is interrupted and the signal handler does not raise an
@@ -4341,7 +4341,7 @@ to be ignored.
43414341
The current process is replaced immediately. Open file objects and
43424342
descriptors are not flushed, so if there may be data buffered
43434343
on these open files, you should flush them using
4344-
:func:`sys.stdout.flush` or :func:`os.fsync` before calling an
4344+
:func:`~io.IOBase.flush` or :func:`os.fsync` before calling an
43454345
:func:`exec\* <execl>` function.
43464346

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

0 commit comments

Comments
 (0)