From 2169d76c1dbd7af49c51682f2d135c91e93c8720 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 28 Nov 2024 11:28:53 +0000 Subject: [PATCH 1/3] Error on verify as str --- httpx/_config.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/httpx/_config.py b/httpx/_config.py index 9318de3c13..2f49f873f4 100644 --- a/httpx/_config.py +++ b/httpx/_config.py @@ -31,6 +31,14 @@ def create_ssl_context(verify: ssl.SSLContext | bool = True) -> ssl.SSLContext: ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE return ssl_context + elif isinstance(verify, str): + # Explicitly handle this deprecated usage pattern. + msg = ( + "verify should be a boolean or SSLContext, since version 0.28. " + "Use `verify=ssl.create_default_context(cafile=...)` " + "or `verify=ssl.create_default_context(capath=...)`." + ) + raise RuntimeError(msg) return verify From 6a1b24d5768032048a7396ee42df6d72ab32d1f2 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 28 Nov 2024 11:39:30 +0000 Subject: [PATCH 2/3] Don't both with coverage for simple runtime error on deprecated usage. Because trade-offs. --- httpx/_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpx/_config.py b/httpx/_config.py index 2f49f873f4..4b03ccde2e 100644 --- a/httpx/_config.py +++ b/httpx/_config.py @@ -31,7 +31,7 @@ def create_ssl_context(verify: ssl.SSLContext | bool = True) -> ssl.SSLContext: ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE return ssl_context - elif isinstance(verify, str): + elif isinstance(verify, str): # pagma: nocover # Explicitly handle this deprecated usage pattern. msg = ( "verify should be a boolean or SSLContext, since version 0.28. " From 8a40ebc44fa32b90edfb45ba3ba57d85ddfc7756 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 28 Nov 2024 11:42:53 +0000 Subject: [PATCH 3/3] Update httpx/_config.py --- httpx/_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpx/_config.py b/httpx/_config.py index 4b03ccde2e..1dec1bd37c 100644 --- a/httpx/_config.py +++ b/httpx/_config.py @@ -31,7 +31,7 @@ def create_ssl_context(verify: ssl.SSLContext | bool = True) -> ssl.SSLContext: ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE return ssl_context - elif isinstance(verify, str): # pagma: nocover + elif isinstance(verify, str): # pragma: nocover # Explicitly handle this deprecated usage pattern. msg = ( "verify should be a boolean or SSLContext, since version 0.28. "