mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
gh-113812: Allow DatagramTransport.sendto to send empty data (#115199)
Also include the UDP packet header sizes (8 bytes per packet) in the buffer size reported to the flow control subsystem.
This commit is contained in:
parent
8db8d7118e
commit
73e8637002
8 changed files with 50 additions and 16 deletions
|
@ -1280,11 +1280,10 @@ class SelectorDatagramTransportTests(test_utils.TestCase):
|
|||
|
||||
def test_sendto_no_data(self):
|
||||
transport = self.datagram_transport()
|
||||
transport._buffer.append((b'data', ('0.0.0.0', 12345)))
|
||||
transport.sendto(b'', ())
|
||||
self.assertFalse(self.sock.sendto.called)
|
||||
transport.sendto(b'', ('0.0.0.0', 1234))
|
||||
self.assertTrue(self.sock.sendto.called)
|
||||
self.assertEqual(
|
||||
[(b'data', ('0.0.0.0', 12345))], list(transport._buffer))
|
||||
self.sock.sendto.call_args[0], (b'', ('0.0.0.0', 1234)))
|
||||
|
||||
def test_sendto_buffer(self):
|
||||
transport = self.datagram_transport()
|
||||
|
@ -1320,6 +1319,18 @@ class SelectorDatagramTransportTests(test_utils.TestCase):
|
|||
list(transport._buffer))
|
||||
self.assertIsInstance(transport._buffer[1][0], bytes)
|
||||
|
||||
def test_sendto_buffer_nodata(self):
|
||||
data2 = b''
|
||||
transport = self.datagram_transport()
|
||||
transport._buffer.append((b'data1', ('0.0.0.0', 12345)))
|
||||
transport.sendto(data2, ('0.0.0.0', 12345))
|
||||
self.assertFalse(self.sock.sendto.called)
|
||||
self.assertEqual(
|
||||
[(b'data1', ('0.0.0.0', 12345)),
|
||||
(b'', ('0.0.0.0', 12345))],
|
||||
list(transport._buffer))
|
||||
self.assertIsInstance(transport._buffer[1][0], bytes)
|
||||
|
||||
def test_sendto_tryagain(self):
|
||||
data = b'data'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue