mirror of
https://github.com/python/cpython.git
synced 2025-12-09 02:35:14 +00:00
Issue #26685: Raise OSError if closing a socket fails
This commit is contained in:
parent
f01e408c16
commit
50ab1a3694
6 changed files with 26 additions and 2 deletions
|
|
@ -277,7 +277,6 @@ class SmallPtyTests(unittest.TestCase):
|
|||
socketpair = self._socketpair()
|
||||
masters = [s.fileno() for s in socketpair]
|
||||
|
||||
os.close(masters[1])
|
||||
socketpair[1].close()
|
||||
os.close(write_to_stdin_fd)
|
||||
|
||||
|
|
|
|||
|
|
@ -1161,6 +1161,17 @@ class GeneralModuleTests(unittest.TestCase):
|
|||
sock.close()
|
||||
self.assertRaises(OSError, sock.send, b"spam")
|
||||
|
||||
def testCloseException(self):
|
||||
sock = socket.socket()
|
||||
socket.socket(fileno=sock.fileno()).close()
|
||||
try:
|
||||
sock.close()
|
||||
except OSError as err:
|
||||
# Winsock apparently raises ENOTSOCK
|
||||
self.assertIn(err.errno, (errno.EBADF, errno.ENOTSOCK))
|
||||
else:
|
||||
self.fail("close() should raise EBADF/ENOTSOCK")
|
||||
|
||||
def testNewAttributes(self):
|
||||
# testing .family, .type and .protocol
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue