Skip to content
Myr

check sys.version_info and ssl.OPENSSL_VERSION_INFO once (#1720)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Thomas Grainger · committed by GitHub · parent 1737fc6 · Browse files · 1 file+9 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−5 removed

  • other:+9 added−5 removed

1 file+9 added−5 removed

modified:httpx/_compat.py+9 added-5 removed
10 unmodified lines
11 from contextlib import asynccontextmanager # type: ignore12except ImportError:13 from async_generator import asynccontextmanager # type: ignore # noqa1415if sys.version_info >= (3, 10) or (16 sys.version_info >= (3, 7) and ssl.OPENSSL_VERSION_INFO >= (1, 1, 0, 7)17):1816def set_minimum_tls_version_1_2(context: ssl.SSLContext) -> None:17 if sys.version_info >= (3, 10) or (18 sys.version_info >= (3, 7) and ssl.OPENSSL_VERSION_INFO >= (1, 1, 0, 7)19 ):19 def set_minimum_tls_version_1_2(context: ssl.SSLContext) -> None:20 # The OP_NO_SSL* and OP_NO_TLS* become deprecated in favor of21 # 'SSLContext.minimum_version' from Python 3.7 onwards, however22 # this attribute is not available unless the ssl module is compiled23 # with OpenSSL 1.1.0g or newer.24 # https://docs.python.org/3.10/library/ssl.html#ssl.SSLContext.minimum_version25 # https://docs.python.org/3.7/library/ssl.html#ssl.SSLContext.minimum_version26 context.minimum_version = ssl.TLSVersion.TLSv1_2272827 else:29else:3031 def set_minimum_tls_version_1_2(context: ssl.SSLContext) -> None:32 # If 'minimum_version' isn't available, we configure these options with33 # the older deprecated variants.34 context.options |= ssl.OP_NO_SSLv235 context.options |= ssl.OP_NO_SSLv3
2 unmodified lines