[3.13] gh-138703: clarify data buffer requirement of asyncio.StreamWriter.write (GH-139564) (#139571)
Some checks are pending
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run

gh-138703: clarify data buffer requirement of `asyncio.StreamWriter.write` (GH-139564)
(cherry picked from commit 0b2168275e)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
Miss Islington (bot) 2025-10-04 18:42:03 +02:00 committed by GitHub
parent bf9d410bf3
commit be388836c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View file

@ -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)

View file

@ -1046,8 +1046,8 @@ class _SelectorSocketTransport(_SelectorTransport):
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: