diff --git a/Lib/asynchat.py b/Lib/asynchat.py index fc1146adbb10dc..0e56a3da66b3e0 100644 --- a/Lib/asynchat.py +++ b/Lib/asynchat.py @@ -191,8 +191,8 @@ def handle_close(self): def push(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): - raise TypeError('data argument must be byte-ish (%r)', - type(data)) + raise TypeError('data argument must be a bytes-like object, not %r' % + type(data).__name__) sabs = self.ac_out_buffer_size if len(data) > sabs: for i in range(0, len(data), sabs): diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index ff12877fae2f23..72146b28ba6ad2 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -232,8 +232,8 @@ class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): - raise TypeError('data argument must be byte-ish (%r)', - type(data)) + raise TypeError('data argument must be a bytes-like object, not %r' % + type(data).__name__) if self._eof_written: raise RuntimeError('write_eof() already called')