From fc7232914e522c016cf208720211c722bd51a2a7 Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Sat, 18 May 2024 12:22:53 -0400 Subject: [PATCH 1/2] Document `socket.makefile()` accepts combined modes ref: #110383 ref: https://mail.python.org/archives/list/docs@python.org/thread/3VGLA6Q6QDYB7XIAHFIRAVW4TQSEAZGA/ --- Doc/library/socket.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 6405f7f00fcb21..2df0257d1f24f0 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -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 From 20ded2e73b8f1dd7db81271bfd65f4f2930e27ec Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 20 May 2024 17:37:35 -0400 Subject: [PATCH 2/2] Document `socket.makefile()` accepts combined modes in `Lib/socket.py` --- Lib/socket.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index 77986fc2e48099..524ce1361b9091 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -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"}: