From a27db4047617c1fa18a53cb818919829c64052ef Mon Sep 17 00:00:00 2001 From: donBarbos Date: Sat, 19 Jul 2025 23:26:15 +0400 Subject: [PATCH 1/4] [ssl] Deprecated several features --- stdlib/ssl.pyi | 53 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 9fbf5e8dfa84..24ac0f4500ad 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -80,18 +80,33 @@ class SSLCertVerificationError(SSLError, ValueError): CertificateError = SSLCertVerificationError if sys.version_info < (3, 12): - def wrap_socket( - sock: socket.socket, - keyfile: StrOrBytesPath | None = None, - certfile: StrOrBytesPath | None = None, - server_side: bool = False, - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: str | None = None, - do_handshake_on_connect: bool = True, - suppress_ragged_eofs: bool = True, - ciphers: str | None = None, - ) -> SSLSocket: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated in Python 3.9; Removed in 3.12.") + def wrap_socket( + sock: socket.socket, + keyfile: StrOrBytesPath | None = None, + certfile: StrOrBytesPath | None = None, + server_side: bool = False, + cert_reqs: int = ..., + ssl_version: int = ..., + ca_certs: str | None = None, + do_handshake_on_connect: bool = True, + suppress_ragged_eofs: bool = True, + ciphers: str | None = None, + ) -> SSLSocket: ... + else: + def wrap_socket( + sock: socket.socket, + keyfile: StrOrBytesPath | None = None, + certfile: StrOrBytesPath | None = None, + server_side: bool = False, + cert_reqs: int = ..., + ssl_version: int = ..., + ca_certs: str | None = None, + do_handshake_on_connect: bool = True, + suppress_ragged_eofs: bool = True, + ciphers: str | None = None, + ) -> SSLSocket: ... def create_default_context( purpose: Purpose = ..., @@ -132,7 +147,11 @@ else: _create_default_https_context: Callable[..., SSLContext] if sys.version_info < (3, 12): - def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ... + if sys.version_info >= (3, 10): + @deprecated("Deprecated in Python 3.9; Removed in 3.12.") + def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ... + else: + def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ... def cert_time_to_seconds(cert_time: str) -> int: ... @@ -416,9 +435,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("ssl.SSLContext() without protocol argument is deprecated.") + def __new__(cls, protocol: None, *args: Any, **kwargs: Any) -> Self: ... else: def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ... From 39c2ea4d7d1813d1b6c75473a8ea71708e059878 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Sat, 19 Jul 2025 23:33:20 +0400 Subject: [PATCH 2/4] Add default value None to second overload --- stdlib/ssl.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 24ac0f4500ad..4c1735fa83dd 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -439,7 +439,7 @@ class SSLContext(_SSLContext): def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ... @overload @deprecated("ssl.SSLContext() without protocol argument is deprecated.") - def __new__(cls, protocol: None, *args: Any, **kwargs: Any) -> Self: ... + def __new__(cls, protocol: None = None, *args: Any, **kwargs: Any) -> Self: ... else: def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ... From 1c091cb3eea5c7e1b77c5ffa294dac1853321b7f Mon Sep 17 00:00:00 2001 From: donBarbos Date: Sun, 20 Jul 2025 09:16:19 +0400 Subject: [PATCH 3/4] Correct deprecated versions --- stdlib/ssl.pyi | 49 ++++++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 4c1735fa83dd..d3f1ef482953 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -80,33 +80,19 @@ class SSLCertVerificationError(SSLError, ValueError): CertificateError = SSLCertVerificationError if sys.version_info < (3, 12): - if sys.version_info >= (3, 10): - @deprecated("Deprecated in Python 3.9; Removed in 3.12.") - def wrap_socket( - sock: socket.socket, - keyfile: StrOrBytesPath | None = None, - certfile: StrOrBytesPath | None = None, - server_side: bool = False, - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: str | None = None, - do_handshake_on_connect: bool = True, - suppress_ragged_eofs: bool = True, - ciphers: str | None = None, - ) -> SSLSocket: ... - else: - def wrap_socket( - sock: socket.socket, - keyfile: StrOrBytesPath | None = None, - certfile: StrOrBytesPath | None = None, - server_side: bool = False, - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: str | None = None, - do_handshake_on_connect: bool = True, - suppress_ragged_eofs: bool = True, - ciphers: str | None = None, - ) -> SSLSocket: ... + @deprecated("Deprecated since Python 3.7; Removed in Python 3.12.") + def wrap_socket( + sock: socket.socket, + keyfile: StrOrBytesPath | None = None, + certfile: StrOrBytesPath | None = None, + server_side: bool = False, + cert_reqs: int = ..., + ssl_version: int = ..., + ca_certs: str | None = None, + do_handshake_on_connect: bool = True, + suppress_ragged_eofs: bool = True, + ciphers: str | None = None, + ) -> SSLSocket: ... def create_default_context( purpose: Purpose = ..., @@ -147,11 +133,8 @@ else: _create_default_https_context: Callable[..., SSLContext] if sys.version_info < (3, 12): - if sys.version_info >= (3, 10): - @deprecated("Deprecated in Python 3.9; Removed in 3.12.") - def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ... - else: - def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ... + @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: ... @@ -438,7 +421,7 @@ class SSLContext(_SSLContext): @overload def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ... @overload - @deprecated("ssl.SSLContext() without protocol argument is deprecated.") + @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: ... From 00dfd91ce4df4d2d0afc430f63ff595113e59253 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Sun, 20 Jul 2025 09:31:00 +0400 Subject: [PATCH 4/4] Update msgs --- stdlib/ssl.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index d3f1ef482953..84d84478886c 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -80,7 +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.") + @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, @@ -133,7 +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.") + @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: ... @@ -421,7 +421,7 @@ class SSLContext(_SSLContext): @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.") + @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: ... 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