diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-31 23:00:55 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-31 23:00:55 (GMT) |
commit | 8315f967647f4610776fef6dda830ce72db042c0 (patch) | |
tree | 70a84128a3e9301c1df0c511b4ae7d5ae61309ca /Lib/socket.py | |
parent | 8612b4c21cfe2fa981fab1084cb7f9f6adafcb62 (diff) | |
parent | 70deb3de3960142fcf8497d2ea0cfae6609b8e66 (diff) | |
download | cpython-8315f967647f4610776fef6dda830ce72db042c0.zip cpython-8315f967647f4610776fef6dda830ce72db042c0.tar.gz cpython-8315f967647f4610776fef6dda830ce72db042c0.tar.bz2 |
Issue #13872: socket.detach() now marks the socket closed (as mirrored in the socket repr()).
Patch by Matt Joiner.
Diffstat (limited to 'Lib/socket.py')
-rw-r--r-- | Lib/socket.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/socket.py b/Lib/socket.py index b2954b5..8b2d1cd 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -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 |