mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
gh-113892: Add a extra check to ProactorEventLoop.sock_connect
to ensure that the given socket is in non-blocking mode (#119519)
This commit is contained in:
parent
ce2ea7d629
commit
cf3bba3f06
3 changed files with 12 additions and 2 deletions
|
@ -1018,9 +1018,9 @@ class ProactorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
self.addCleanup(self.file.close)
|
||||
super().setUp()
|
||||
|
||||
def make_socket(self, cleanup=True):
|
||||
def make_socket(self, cleanup=True, blocking=False):
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.setblocking(False)
|
||||
sock.setblocking(blocking)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1024)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 1024)
|
||||
if cleanup:
|
||||
|
@ -1082,6 +1082,11 @@ class ProactorEventLoopUnixSockSendfileTests(test_utils.TestCase):
|
|||
0, None))
|
||||
self.assertEqual(self.file.tell(), 0)
|
||||
|
||||
def test_blocking_socket(self):
|
||||
self.loop.set_debug(True)
|
||||
sock = self.make_socket(blocking=True)
|
||||
with self.assertRaisesRegex(ValueError, "must be non-blocking"):
|
||||
self.run_loop(self.loop.sock_sendfile(sock, self.file))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue