aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/asyncio/streams.py
diff options
context:
space:
mode:
authorDarioDaF <dario.fagotto@gmail.com>2022-12-11 00:07:02 +0100
committerGitHub <noreply@github.com>2022-12-10 15:07:02 -0800
commit1bb68ba6d9de6bb7f00aee11d135123163f15887 (patch)
tree1be51c00ff9587e32cd497b2948506b65f7cbf4b /Lib/asyncio/streams.py
parentd5f8a2b6ad408368e728a389da918cead3ef7ee9 (diff)
downloadcpython-1bb68ba6d9de6bb7f00aee11d135123163f15887.tar.gz
cpython-1bb68ba6d9de6bb7f00aee11d135123163f15887.zip
gh-99941: Ensure that asyncio.Protocol.data_received receives immutable bytes (#100053)
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r--Lib/asyncio/streams.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index 3bd99043d09..0f9098b4195 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -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