mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-99941: Ensure that asyncio.Protocol.data_received receives immutable bytes (#100053)
This commit is contained in:
parent
d5f8a2b6ad
commit
1bb68ba6d9
4 changed files with 10 additions and 4 deletions
|
@ -688,7 +688,7 @@ class StreamReader:
|
|||
await self._wait_for_data('read')
|
||||
|
||||
# This will work right even if buffer is less than n bytes
|
||||
data = bytes(self._buffer[:n])
|
||||
data = bytes(memoryview(self._buffer)[:n])
|
||||
del self._buffer[:n]
|
||||
|
||||
self._maybe_resume_transport()
|
||||
|
@ -730,7 +730,7 @@ class StreamReader:
|
|||
data = bytes(self._buffer)
|
||||
self._buffer.clear()
|
||||
else:
|
||||
data = bytes(self._buffer[:n])
|
||||
data = bytes(memoryview(self._buffer)[:n])
|
||||
del self._buffer[:n]
|
||||
self._maybe_resume_transport()
|
||||
return data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue