mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Close #22063: socket operations (socket,recv, sock_sendall, sock_connect,
sock_accept) now raise an exception in debug mode if sockets are in blocking mode.
This commit is contained in:
parent
f2ed889027
commit
9c9f1f10d3
3 changed files with 34 additions and 0 deletions
|
@ -383,6 +383,24 @@ class EventLoopTestsMixin:
|
|||
self.assertEqual(read, data)
|
||||
|
||||
def _basetest_sock_client_ops(self, httpd, sock):
|
||||
# in debug mode, socket operations must fail
|
||||
# if the socket is not in blocking mode
|
||||
self.loop.set_debug(True)
|
||||
sock.setblocking(True)
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(
|
||||
self.loop.sock_connect(sock, httpd.address))
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(
|
||||
self.loop.sock_sendall(sock, b'GET / HTTP/1.0\r\n\r\n'))
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(
|
||||
self.loop.sock_recv(sock, 1024))
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(
|
||||
self.loop.sock_accept(sock))
|
||||
|
||||
# test in non-blocking mode
|
||||
sock.setblocking(False)
|
||||
self.loop.run_until_complete(
|
||||
self.loop.sock_connect(sock, httpd.address))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue