Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ async def sendfile(self, transport, file, offset=0, count=None,
raise

if not fallback:
raise RuntimeError(
raise exceptions.SendfileNotAvailableError(
f"fallback is disabled and native sendfile is not "
f"supported for transport {transport!r}")
return await self._sendfile_fallback(transport, file,
Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_asyncio/test_sendfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def test_sendfile_not_supported(self):
try:
with self.assertRaisesRegex(RuntimeError, "not supported"):
self.run_loop(
self.loop.sendfile(tr, self.file))
self.loop.sendfile(tr, self.file, fallback=False))
self.assertEqual(0, self.file.tell())
finally:
# don't use self.addCleanup because it produces resource warning
Expand Down Expand Up @@ -580,7 +580,8 @@ def test_sendfile_no_fallback_for_fallback_transport(self):
transport = mock.Mock()
transport.is_closing.side_effect = lambda: False
transport._sendfile_compatible = constants._SendfileMode.FALLBACK
with self.assertRaisesRegex(RuntimeError, 'fallback is disabled'):
with self.assertRaisesRegex(asyncio.SendfileNotAvailableError,
'fallback is disabled'):
self.loop.run_until_complete(
self.loop.sendfile(transport, None, fallback=False))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``asyncio``'s ``loop.sendfile(..., fallback=False)`` now consistently raises
:exc:`asyncio.SendfileNotAvailableError` for fallback-only transports, such as
SSL/TLS transports, when native sendfile cannot be used. Previously, this case
raised :exc:`RuntimeError`.
Loading