diff -r b6284d2aaada Doc/library/socket.rst --- a/Doc/library/socket.rst Sun Jan 06 16:14:22 2013 -0500 +++ b/Doc/library/socket.rst Fri Jan 11 13:04:56 2013 +0100 @@ -827,7 +827,9 @@ 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. + interpreted the same way as by the built-in :func:`open` function, except the + only mode characters supported are ``'r'``, ``'w'``, ``'b'`` and ``'t'``. The + default mode is ``'r'`` (open for reading text, synonym of ``'rt'``). Closing the file object won't close the socket unless there are no remaining references to the socket. The socket must be in blocking mode; it can have diff -r b6284d2aaada Lib/socket.py --- a/Lib/socket.py Sun Jan 06 16:14:22 2013 -0500 +++ b/Lib/socket.py Fri Jan 11 13:04:56 2013 +0100 @@ -146,16 +146,20 @@ """makefile(...) -> an I/O stream connected to the socket The arguments are as for io.open() after the filename, - except the only mode characters supported are 'r', 'w' and 'b'. - The semantics are similar too. (XXX refactor to share code?) + except the only mode characters supported are 'r', 'w', 'b' and + (default) 't'. The semantics are similar too. (XXX refactor to + share code?) """ for c in mode: - if c not in {"r", "w", "b"}: - raise ValueError("invalid mode %r (only r, w, b allowed)") + if c not in {"r", "w", "b", "t"}: + raise ValueError("invalid mode %r (only r, w, b, t allowed)") writing = "w" in mode reading = "r" in mode or not writing assert reading or writing binary = "b" in mode + text = "t" in mode or not binary + if binary and text: + raise ValueError("modes t and b cannot be used simultaneously") rawmode = "" if reading: rawmode += "r"