[ssl] Deprecate several features (#14432)

This commit is contained in:
Semyon Moroz
2025-07-26 14:54:23 +00:00
committed by GitHub
parent 6e474f2d0f
commit bdd6546471
+7 -3
View File
@@ -80,6 +80,7 @@ class SSLCertVerificationError(SSLError, ValueError):
CertificateError = SSLCertVerificationError
if sys.version_info < (3, 12):
@deprecated("Deprecated since Python 3.7. Removed in Python 3.12. Use `SSLContext.wrap_socket()` instead.")
def wrap_socket(
sock: socket.socket,
keyfile: StrOrBytesPath | None = None,
@@ -132,6 +133,7 @@ else:
_create_default_https_context: Callable[..., SSLContext]
if sys.version_info < (3, 12):
@deprecated("Deprecated since Python 3.7. Removed in Python 3.12.")
def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ...
def cert_time_to_seconds(cert_time: str) -> int: ...
@@ -416,9 +418,11 @@ class SSLContext(_SSLContext):
if sys.version_info >= (3, 10):
security_level: int
if sys.version_info >= (3, 10):
# Using the default (None) for the `protocol` parameter is deprecated,
# but there isn't a good way of marking that in the stub unless/until PEP 702 is accepted
def __new__(cls, protocol: int | None = None, *args: Any, **kwargs: Any) -> Self: ...
@overload
def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ...
@overload
@deprecated("Deprecated since Python 3.10. Use a specific version of the SSL protocol.")
def __new__(cls, protocol: None = None, *args: Any, **kwargs: Any) -> Self: ...
else:
def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ...