https://github.com/python/cpython/commit/8566ee25073b237bfaed0f886c83d9933ffc6fe7
commit: 8566ee25073b237bfaed0f886c83d9933ffc6fe7
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2025-10-04T16:40:21Z
summary:

[3.14] gh-138703: clarify data buffer requirement of 
`asyncio.StreamWriter.write` (GH-139564) (#139570)

Co-authored-by: Kumar Aditya <[email protected]>

files:
M Doc/library/asyncio-stream.rst
M Lib/asyncio/selector_events.py

diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst
index e1568ae330b70f..05445219510ca5 100644
--- a/Doc/library/asyncio-stream.rst
+++ b/Doc/library/asyncio-stream.rst
@@ -316,13 +316,14 @@ StreamWriter
       If that fails, the data is queued in an internal write buffer until it 
can be
       sent.
 
+      The *data* buffer should be a bytes, bytearray, or C-contiguous 
one-dimensional
+      memoryview object.
+
       The method should be used along with the ``drain()`` method::
 
          stream.write(data)
          await stream.drain()
 
-      .. note::
-         The *data* buffer should be a C contiguous one-dimensional 
:term:`bytes-like object <bytes-like object>`.
 
    .. method:: writelines(data)
 
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index 6ad84044adf146..f8744cbb223003 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -1050,8 +1050,8 @@ def _read_ready__on_eof(self):
 
     def write(self, data):
         if not isinstance(data, (bytes, bytearray, memoryview)):
-            raise TypeError(f'data argument must be a bytes-like object, '
-                            f'not {type(data).__name__!r}')
+            raise TypeError(f'data argument must be a bytes, bytearray, or 
memoryview '
+                            f'object, not {type(data).__name__!r}')
         if self._eof:
             raise RuntimeError('Cannot call write() after write_eof()')
         if self._empty_waiter is not None:

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to