Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 12 additions & 2 deletions Lib/test/test_asyncio/test_sendfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for sendfile functionality."""

import asyncio
import errno
import os
import socket
import sys
Expand Down Expand Up @@ -484,8 +485,17 @@ def sendfile_native(transp, file, offset, count):

srv_proto, cli_proto = self.prepare_sendfile(close_after=1024)
with self.assertRaises(ConnectionError):
self.run_loop(
self.loop.sendfile(cli_proto.transport, self.file))
try:
self.run_loop(
self.loop.sendfile(cli_proto.transport, self.file))
except OSError as e:
# macOS may raise OSError of EPROTOTYPE when writing to a
# socket that is in the process of closing down.
if e.errno == errno.EPROTOTYPE and sys.platform == "darwin":
raise ConnectionError from e
else:
raise

self.run_loop(srv_proto.done)

self.assertTrue(1024 <= srv_proto.nbytes < len(self.DATA),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update test case `test_sendfile_fallback_close_peer_in_the_middle_of_receiving` to handle `OSError` of `EPROTOTYPE` on macOS.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test only changes do not need NEWS entries.
They are for user-facing things :)