From 9c945e309e5906850286d0fe10210613495e275f Mon Sep 17 00:00:00 2001 From: fancidev Date: Sun, 16 Oct 2022 11:56:01 +0800 Subject: [PATCH 1/4] Handle EPROTOTYPE under macOS in test_sendfile_fallback_close_peer_in_the_middle_of_receiving. --- Lib/test/test_asyncio/test_sendfile.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_asyncio/test_sendfile.py b/Lib/test/test_asyncio/test_sendfile.py index a10504b1c4130e..30299d22f8c3b4 100644 --- a/Lib/test/test_asyncio/test_sendfile.py +++ b/Lib/test/test_asyncio/test_sendfile.py @@ -1,6 +1,7 @@ """Tests for sendfile functionality.""" import asyncio +import errno import os import socket import sys @@ -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), From 7747f31f9e1a98056147558306c70caaa16d46f8 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 16 Oct 2022 06:42:02 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst diff --git a/Misc/NEWS.d/next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst b/Misc/NEWS.d/next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst new file mode 100644 index 00000000000000..d8855ac11947b0 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst @@ -0,0 +1 @@ +Update test case `test_sendfile_fallback_close_peer_in_the_middle_of_receiving` to handle `OSError` of `EPROTOTYPE` on macOS. From cf9178a3baab94fcee1e9dbbd6d58e3f246767d2 Mon Sep 17 00:00:00 2001 From: fancidev Date: Mon, 17 Oct 2022 20:43:56 +0800 Subject: [PATCH 3/4] No need to raise 'from' within except block. Co-authored-by: Nikita Sobolev --- Lib/test/test_asyncio/test_sendfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_asyncio/test_sendfile.py b/Lib/test/test_asyncio/test_sendfile.py index 30299d22f8c3b4..0198da21d77028 100644 --- a/Lib/test/test_asyncio/test_sendfile.py +++ b/Lib/test/test_asyncio/test_sendfile.py @@ -492,7 +492,7 @@ def sendfile_native(transp, file, offset, count): # 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 + raise ConnectionError else: raise From 614d6a55305ce3bc15eea4d2c8dddcd1739b6c9e Mon Sep 17 00:00:00 2001 From: fancidev Date: Mon, 17 Oct 2022 21:11:32 +0800 Subject: [PATCH 4/4] NEWS entry not needed for changes to test cases. --- .../next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst diff --git a/Misc/NEWS.d/next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst b/Misc/NEWS.d/next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst deleted file mode 100644 index d8855ac11947b0..00000000000000 --- a/Misc/NEWS.d/next/Tests/2022-10-16-06-42-01.gh-issue-98174.msZY0C.rst +++ /dev/null @@ -1 +0,0 @@ -Update test case `test_sendfile_fallback_close_peer_in_the_middle_of_receiving` to handle `OSError` of `EPROTOTYPE` on macOS. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy