summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/base_events.py4
-rw-r--r--Lib/test/test_asyncio/test_events.py3
2 files changed, 4 insertions, 3 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index a9660ca108..52134372fa 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -827,7 +827,7 @@ class BaseEventLoop(events.AbstractEventLoop):
read = await self.run_in_executor(None, file.readinto, view)
if not read:
break # EOF
- await self.sock_sendall(sock, view)
+ await self.sock_sendall(sock, view[:read])
total_sent += read
return total_sent
finally:
@@ -1082,7 +1082,7 @@ class BaseEventLoop(events.AbstractEventLoop):
if not read:
return total_sent # EOF
await proto.drain()
- transp.write(view)
+ transp.write(view[:read])
total_sent += read
finally:
if total_sent > 0 and hasattr(file, 'seek'):
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 9466111b8e..d2c1d7c8a6 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -2117,7 +2117,8 @@ class SubprocessTestsMixin:
class SendfileBase:
- DATA = b"SendfileBaseData" * (1024 * 8) # 128 KiB
+ # 128 KiB plus small unaligned to buffer chunk
+ DATA = b"SendfileBaseData" * (1024 * 8 + 1)
# Reduce socket buffer size to test on relative small data sets.
BUF_SIZE = 4 * 1024 # 4 KiB