From fecf9d6d4c41f688f92331a0306a5ed8ed939b81 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 27 Sep 2024 11:49:19 +0100 Subject: [PATCH 1/3] Handle import of `trio` raising `NotImplementedError` on unsupported platforms. Closes #946 --- httpcore/_synchronization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpcore/_synchronization.py b/httpcore/_synchronization.py index 9619a3983..50cfefe0a 100644 --- a/httpcore/_synchronization.py +++ b/httpcore/_synchronization.py @@ -9,7 +9,7 @@ try: import trio -except ImportError: # pragma: nocover +except (ImportError, NotImplementedError): # pragma: nocover trio = None # type: ignore try: From dbce3467e5b63843f02c1231c55b9e36ce37adc8 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 27 Sep 2024 12:13:51 +0100 Subject: [PATCH 2/3] Add pragma no cover to deal with oddly misbehaving test --- httpcore/_backends/anyio.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpcore/_backends/anyio.py b/httpcore/_backends/anyio.py index 72d03ffbf..d469e0084 100644 --- a/httpcore/_backends/anyio.py +++ b/httpcore/_backends/anyio.py @@ -104,9 +104,9 @@ async def connect_tcp( timeout: typing.Optional[float] = None, local_address: typing.Optional[str] = None, socket_options: typing.Optional[typing.Iterable[SOCKET_OPTION]] = None, - ) -> AsyncNetworkStream: + ) -> AsyncNetworkStream: # pragma: nocover if socket_options is None: - socket_options = [] # pragma: no cover + socket_options = [] exc_map = { TimeoutError: ConnectTimeout, OSError: ConnectError, @@ -120,7 +120,7 @@ async def connect_tcp( local_host=local_address, ) # By default TCP sockets opened in `asyncio` include TCP_NODELAY. - for option in socket_options: # pragma: nocover + for option in socket_options: stream._raw_socket.setsockopt(*option) # type: ignore[attr-defined] # pragma: no cover return AnyIOStream(stream) From 7b1e27c0c1d3aeb7ccab9abdc72e21ab877b19e1 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 27 Sep 2024 12:24:39 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 992dcff6e..99b1dc0f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased -- Handle `SSLError` exception. (#918) +- Handle `trio` raising `NotImplementedError` on unsupported platforms. (#955) +- Handle mapping `ssl.SSLError` to `httpcore.ConnectError`. (#918) ## 1.0.5 (March 27th, 2024)