Skip to content

Commit

Permalink
gh-110383: Document socket.makefile() accepts combined modes (#119150)
Browse files Browse the repository at this point in the history
The supported mode values are 'r', 'w', and 'b', or a combination of those.
  • Loading branch information
squeakyboots committed May 21, 2024
1 parent 0398d93 commit 62a29be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,8 @@ to sockets.
Return a :term:`file object` associated with the socket. The exact returned
type depends on the arguments given to :meth:`makefile`. These arguments are
interpreted the same way as by the built-in :func:`open` function, except
the only supported *mode* values are ``'r'`` (default), ``'w'`` and ``'b'``.
the only supported *mode* values are ``'r'`` (default), ``'w'``, ``'b'``, or
a combination of those.

The socket must be in blocking mode; it can have a timeout, but the file
object's internal buffer may end up in an inconsistent state if a timeout
Expand Down
3 changes: 2 additions & 1 deletion Lib/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ def makefile(self, mode="r", buffering=None, *,
"""makefile(...) -> an I/O stream connected to the socket
The arguments are as for io.open() after the filename, except the only
supported mode values are 'r' (default), 'w' and 'b'.
supported mode values are 'r' (default), 'w', 'b', or a combination of
those.
"""
# XXX refactor to share code?
if not set(mode) <= {"r", "w", "b"}:
Expand Down

0 comments on commit 62a29be

Please sign in to comment.