bpo-37279: Fix asyncio sendfile support when extra data are sent in fallback mode. (GH-14075)
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index e002539..90de858 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -861,7 +861,7 @@
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:
@@ -1145,7 +1145,7 @@
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'):