Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/asyncio/proactor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ def _force_close(self, exc):

def sendto(self, data, addr=None):
if not isinstance(data, (bytes, bytearray, memoryview)):
raise TypeError('data argument must be bytes-like object (%r)',
type(data))
raise TypeError(f'data argument must be a bytes-like object, '
f'not {type(data).__name__!r}')

if self._address is not None and addr not in (None, self._address):
raise ValueError(
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_asyncio/test_proactor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,9 @@ def test_sendto_error_received_connected(self):

def test_sendto_str(self):
transport = self.datagram_transport()
self.assertRaises(TypeError, transport.sendto, 'str', ())
self.assertRaisesRegex(
TypeError, "^data argument must be a bytes-like object, not 'str'$",
transport.sendto, 'str', ())

def test_sendto_connected_addr(self):
transport = self.datagram_transport(address=('0.0.0.0', 1))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix the error message for invalid data passed to
:meth:`!asyncio.proactor_events.sendto`.
Loading