mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #10041: The signature of optional arguments in socket.makefile()
didn't match that of io.open(), and they also didn't get forwarded properly to TextIOWrapper in text mode. Patch by Kai Zhu.
This commit is contained in:
parent
f2b1909e0f
commit
834bd81c51
5 changed files with 129 additions and 73 deletions
|
@ -133,7 +133,7 @@ class socket(_socket.socket):
|
|||
return socket(self.family, self.type, self.proto, fileno=fd), addr
|
||||
|
||||
def makefile(self, mode="r", buffering=None, *,
|
||||
encoding=None, newline=None):
|
||||
encoding=None, errors=None, newline=None):
|
||||
"""makefile(...) -> an I/O stream connected to the socket
|
||||
|
||||
The arguments are as for io.open() after the filename,
|
||||
|
@ -171,7 +171,7 @@ class socket(_socket.socket):
|
|||
buffer = io.BufferedWriter(raw, buffering)
|
||||
if binary:
|
||||
return buffer
|
||||
text = io.TextIOWrapper(buffer, encoding, newline)
|
||||
text = io.TextIOWrapper(buffer, encoding, errors, newline)
|
||||
text.mode = mode
|
||||
return text
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue