mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
Issue #21119: asyncio: Make sure that socketpair() close sockets on error
Close the listening socket if sock.bind() raises an exception.
This commit is contained in:
parent
223a624158
commit
a9fa2664ab
2 changed files with 26 additions and 15 deletions
|
@ -51,6 +51,15 @@ class WinsocketpairTests(unittest.TestCase):
|
|||
self.assertRaises(ValueError,
|
||||
windows_utils.socketpair, proto=1)
|
||||
|
||||
@mock.patch('asyncio.windows_utils.socket')
|
||||
def test_winsocketpair_close(self, m_socket):
|
||||
m_socket.AF_INET = socket.AF_INET
|
||||
m_socket.SOCK_STREAM = socket.SOCK_STREAM
|
||||
sock = mock.Mock()
|
||||
m_socket.socket.return_value = sock
|
||||
sock.bind.side_effect = OSError
|
||||
self.assertRaises(OSError, windows_utils.socketpair)
|
||||
self.assertTrue(sock.close.called)
|
||||
|
||||
|
||||
class PipeTests(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue