summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/selector_events.py
diff options
context:
space:
mode:
authorJamie Phan <jamie@ordinarylab.dev>2024-02-17 02:38:07 (GMT)
committerGitHub <noreply@github.com>2024-02-17 02:38:07 (GMT)
commit73e8637002639e565938d3f205bf46e7f1dbd6a8 (patch)
tree4c1b1f816c5d5dd9817e63bfd80fa2ea2f2688bc /Lib/asyncio/selector_events.py
parent8db8d7118e1ef22bc7cdc3d8b657bc10c22c2fd6 (diff)
downloadcpython-73e8637002639e565938d3f205bf46e7f1dbd6a8.zip
cpython-73e8637002639e565938d3f205bf46e7f1dbd6a8.tar.gz
cpython-73e8637002639e565938d3f205bf46e7f1dbd6a8.tar.bz2
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.
Diffstat (limited to 'Lib/asyncio/selector_events.py')
-rw-r--r--Lib/asyncio/selector_events.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index 10fbdd7..8e888d2 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -1241,8 +1241,6 @@ class _SelectorDatagramTransport(_SelectorTransport, transports.DatagramTranspor
if not isinstance(data, (bytes, bytearray, memoryview)):
raise TypeError(f'data argument must be a bytes-like object, '
f'not {type(data).__name__!r}')
- if not data:
- return
if self._address:
if addr not in (None, self._address):
@@ -1278,7 +1276,7 @@ class _SelectorDatagramTransport(_SelectorTransport, transports.DatagramTranspor
# Ensure that what we buffer is immutable.
self._buffer.append((bytes(data), addr))
- self._buffer_size += len(data)
+ self._buffer_size += len(data) + 8 # include header bytes
self._maybe_pause_protocol()
def _sendto_ready(self):