mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Follow-up of r67300: correct a failure in socket.makefile().
SocketIO objects now always have 'name' and 'mode' attributes.
This commit is contained in:
parent
304da21138
commit
9d24ff027f
2 changed files with 16 additions and 5 deletions
|
@ -149,8 +149,6 @@ class socket(_socket.socket):
|
|||
if buffering == 0:
|
||||
if not binary:
|
||||
raise ValueError("unbuffered streams must be binary")
|
||||
raw.name = self.fileno()
|
||||
raw.mode = mode
|
||||
return raw
|
||||
if reading and writing:
|
||||
buffer = io.BufferedRWPair(raw, raw, buffering)
|
||||
|
@ -160,11 +158,8 @@ class socket(_socket.socket):
|
|||
assert writing
|
||||
buffer = io.BufferedWriter(raw, buffering)
|
||||
if binary:
|
||||
buffer.name = self.fileno()
|
||||
buffer.mode = mode
|
||||
return buffer
|
||||
text = io.TextIOWrapper(buffer, encoding, newline)
|
||||
text.name = self.fileno()
|
||||
text.mode = mode
|
||||
return text
|
||||
|
||||
|
@ -230,6 +225,14 @@ class SocketIO(io.RawIOBase):
|
|||
def fileno(self):
|
||||
return self._sock.fileno()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._sock.fileno()
|
||||
|
||||
@property
|
||||
def mode(self):
|
||||
return self._mode
|
||||
|
||||
def close(self):
|
||||
if self.closed:
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue