mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #13872: socket.detach() now marks the socket closed (as mirrored in the socket repr()).
Patch by Matt Joiner.
This commit is contained in:
commit
8315f96764
3 changed files with 15 additions and 0 deletions
|
@ -199,6 +199,17 @@ class socket(_socket.socket):
|
|||
if self._io_refs <= 0:
|
||||
self._real_close()
|
||||
|
||||
def detach(self):
|
||||
"""detach() -> file descriptor
|
||||
|
||||
Close the socket object without closing the underlying file descriptor.
|
||||
The object cannot be used after this call, but the file descriptor
|
||||
can be reused for other purposes. The file descriptor is returned.
|
||||
"""
|
||||
self._closed = True
|
||||
return super().detach()
|
||||
|
||||
|
||||
def fromfd(fd, family, type, proto=0):
|
||||
""" fromfd(fd, family, type[, proto]) -> socket object
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue