Skip to content

Commit 099dc56

Browse files
committed
Better exception type when sendfile is not available
1 parent 967408e commit 099dc56

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Lib/asyncio/base_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,12 +659,12 @@ async def sock_sendfile(self, sock, file, offset=0, count=None,
659659
try:
660660
return await self._sock_sendfile_native(sock, file,
661661
offset, count)
662-
except _SendfileNotAvailable:
662+
except _SendfileNotAvailable as exc:
663663
if fallback:
664664
return await self._sock_sendfile_fallback(sock, file,
665665
offset, count)
666666
else:
667-
raise
667+
raise RuntimeError(exc.args[0]) from None
668668

669669
async def _sock_sendfile_native(self, sock, file, offset, count):
670670
raise _SendfileNotAvailable("Fast sendfile is not available")

Lib/test/test_asyncio/test_base_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ def test__sock_sendfile_native_failure(self):
18711871
def test_sock_sendfile_no_fallback(self):
18721872
sock, proto = self.prepare()
18731873

1874-
with self.assertRaisesRegex(base_events._SendfileNotAvailable,
1874+
with self.assertRaisesRegex(RuntimeError,
18751875
"Fast sendfile is not available"):
18761876
self.run_loop(self.loop.sock_sendfile(sock, self.file,
18771877
fallback=False))

0 commit comments

Comments
 (0)