Skip to content

Commit bf41dcd

Browse files
[3.11] gh-101100: Fix Sphinx warnings for fileno (GH-111118) (#111227)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 09bd752 commit bf41dcd

File tree

8 files changed

+49
-13
lines changed

8 files changed

+49
-13
lines changed

Doc/library/bz2.rst

+43-5
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The :mod:`bz2` module contains:
9191
and :meth:`~io.IOBase.truncate`.
9292
Iteration and the :keyword:`with` statement are supported.
9393

94-
:class:`BZ2File` also provides the following method:
94+
:class:`BZ2File` also provides the following methods:
9595

9696
.. method:: peek([n])
9797

@@ -106,14 +106,52 @@ The :mod:`bz2` module contains:
106106

107107
.. versionadded:: 3.3
108108

109+
.. method:: fileno()
110+
111+
Return the file descriptor for the underlying file.
112+
113+
.. versionadded:: 3.3
114+
115+
.. method:: readable()
116+
117+
Return whether the file was opened for reading.
118+
119+
.. versionadded:: 3.3
120+
121+
.. method:: seekable()
122+
123+
Return whether the file supports seeking.
124+
125+
.. versionadded:: 3.3
126+
127+
.. method:: writable()
128+
129+
Return whether the file was opened for writing.
130+
131+
.. versionadded:: 3.3
132+
133+
.. method:: read1(size=-1)
134+
135+
Read up to *size* uncompressed bytes, while trying to avoid
136+
making multiple reads from the underlying stream. Reads up to a
137+
buffer's worth of data if size is negative.
138+
139+
Returns ``b''`` if the file is at EOF.
140+
141+
.. versionadded:: 3.3
142+
143+
.. method:: readinto(b)
144+
145+
Read bytes into *b*.
146+
147+
Returns the number of bytes read (0 for EOF).
148+
149+
.. versionadded:: 3.3
150+
109151

110152
.. versionchanged:: 3.1
111153
Support for the :keyword:`with` statement was added.
112154

113-
.. versionchanged:: 3.3
114-
The :meth:`fileno`, :meth:`readable`, :meth:`seekable`, :meth:`writable`,
115-
:meth:`read1` and :meth:`readinto` methods were added.
116-
117155
.. versionchanged:: 3.3
118156
Support was added for *filename* being a :term:`file object` instead of an
119157
actual filename.

Doc/library/mmap.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ the current file position, and :meth:`seek` through the file to different positi
1919
A memory-mapped file is created by the :class:`~mmap.mmap` constructor, which is
2020
different on Unix and on Windows. In either case you must provide a file
2121
descriptor for a file opened for update. If you wish to map an existing Python
22-
file object, use its :meth:`fileno` method to obtain the correct value for the
22+
file object, use its :meth:`~io.IOBase.fileno` method to obtain the correct value for the
2323
*fileno* parameter. Otherwise, you can open the file using the
2424
:func:`os.open` function, which returns a file descriptor directly (the file
2525
still needs to be closed when done).

Doc/library/multiprocessing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ multiple connections at the same time.
25402540
**Windows**: An item in *object_list* must either be an integer
25412541
handle which is waitable (according to the definition used by the
25422542
documentation of the Win32 function ``WaitForMultipleObjects()``)
2543-
or it can be an object with a :meth:`fileno` method which returns a
2543+
or it can be an object with a :meth:`~io.IOBase.fileno` method which returns a
25442544
socket handle or pipe handle. (Note that pipe handles and socket
25452545
handles are **not** waitable handles.)
25462546

Doc/library/selectors.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ It defines a :class:`BaseSelector` abstract base class, along with several
2121
concrete implementations (:class:`KqueueSelector`, :class:`EpollSelector`...),
2222
that can be used to wait for I/O readiness notification on multiple file
2323
objects. In the following, "file object" refers to any object with a
24-
:meth:`fileno()` method, or a raw file descriptor. See :term:`file object`.
24+
:meth:`~io.IOBase.fileno` method, or a raw file descriptor. See :term:`file object`.
2525

2626
:class:`DefaultSelector` is an alias to the most efficient implementation
2727
available on the current platform: this should be the default choice for most

Doc/library/socket.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ The following functions all create :ref:`socket objects <socket-objects>`.
759759
.. function:: fromfd(fd, family, type, proto=0)
760760

761761
Duplicate the file descriptor *fd* (an integer as returned by a file object's
762-
:meth:`fileno` method) and build a socket object from the result. Address
762+
:meth:`~io.IOBase.fileno` method) and build a socket object from the result. Address
763763
family, socket type and protocol number are as for the :func:`.socket` function
764764
above. The file descriptor should refer to a socket, but this is not checked ---
765765
subsequent operations on the object may fail if the file descriptor is invalid.

Doc/library/tempfile.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ The module defines the following user-callable items:
103103

104104
This class operates exactly as :func:`TemporaryFile` does, except that
105105
data is spooled in memory until the file size exceeds *max_size*, or
106-
until the file's :func:`fileno` method is called, at which point the
106+
until the file's :func:`~io.IOBase.fileno` method is called, at which point the
107107
contents are written to disk and operation proceeds as with
108108
:func:`TemporaryFile`.
109109

Doc/tools/.nitignore

-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Doc/library/asyncio-subprocess.rst
3939
Doc/library/asyncio-task.rst
4040
Doc/library/bdb.rst
4141
Doc/library/bisect.rst
42-
Doc/library/bz2.rst
4342
Doc/library/calendar.rst
4443
Doc/library/cmd.rst
4544
Doc/library/collections.abc.rst
@@ -104,7 +103,6 @@ Doc/library/reprlib.rst
104103
Doc/library/resource.rst
105104
Doc/library/rlcompleter.rst
106105
Doc/library/select.rst
107-
Doc/library/selectors.rst
108106
Doc/library/shelve.rst
109107
Doc/library/signal.rst
110108
Doc/library/smtplib.rst

Doc/whatsnew/2.5.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ complete list of changes, or look through the SVN logs for all the details.
13471347
:func:`input` function to allow opening files in binary or :term:`universal
13481348
newlines` mode. Another new parameter, *openhook*, lets you use a function
13491349
other than :func:`open` to open the input files. Once you're iterating over
1350-
the set of files, the :class:`FileInput` object's new :meth:`fileno` returns
1350+
the set of files, the :class:`FileInput` object's new :meth:`~fileinput.fileno` returns
13511351
the file descriptor for the currently opened file. (Contributed by Georg
13521352
Brandl.)
13531353

0 commit comments

Comments
 (0)