From 9d0ed1571fea2ed443ea821939749bebe1d498c9 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 9 Aug 2023 10:18:33 +0300 Subject: [PATCH] Update `ssl` to 3.12 (#10547) --- stdlib/ssl.pyi | 35 ++++++++++++++++++----------- tests/stubtest_allowlists/py312.txt | 4 ---- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index bc4c5bc55..dd7285196 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -44,18 +44,20 @@ class SSLCertVerificationError(SSLError, ValueError): CertificateError = SSLCertVerificationError -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, 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 = ..., *, @@ -95,7 +97,10 @@ else: _create_default_https_context: Callable[..., SSLContext] def RAND_bytes(__n: int) -> bytes: ... -def RAND_pseudo_bytes(__n: int) -> tuple[bytes, bool]: ... + +if sys.version_info < (3, 12): + def RAND_pseudo_bytes(__n: int) -> tuple[bytes, bool]: ... + def RAND_status() -> bool: ... def RAND_egd(path: str) -> None: ... def RAND_add(__string: str | ReadableBuffer, __entropy: float) -> None: ... @@ -198,6 +203,8 @@ class Options(enum.IntFlag): OP_ENABLE_MIDDLEBOX_COMPAT: int if sys.platform == "linux": OP_IGNORE_UNEXPECTED_EOF: int + if sys.version_info >= (3, 12): + OP_LEGACY_SERVER_CONNECT: int if sys.version_info >= (3, 12) and sys.platform != "linux": OP_ENABLE_KTLS: int OP_IGNORE_UNEXPECTED_EOF: int @@ -219,6 +226,8 @@ if sys.version_info >= (3, 8): OP_ENABLE_MIDDLEBOX_COMPAT: Options if sys.platform == "linux": OP_IGNORE_UNEXPECTED_EOF: Options +if sys.version_info >= (3, 12): + OP_LEGACY_SERVER_CONNECT: Options if sys.version_info >= (3, 12) and sys.platform != "linux": OP_ENABLE_KTLS: Options OP_IGNORE_UNEXPECTED_EOF: Options diff --git a/tests/stubtest_allowlists/py312.txt b/tests/stubtest_allowlists/py312.txt index a5558fade..6222c60f0 100644 --- a/tests/stubtest_allowlists/py312.txt +++ b/tests/stubtest_allowlists/py312.txt @@ -60,10 +60,6 @@ smtplib.SMTP_SSL.__init__ sre_parse.Tokenizer.checkgroupname sre_parse.expand_template sre_parse.parse_template -ssl.OP_LEGACY_SERVER_CONNECT -ssl.Options.OP_LEGACY_SERVER_CONNECT -ssl.RAND_pseudo_bytes -ssl.wrap_socket turtle.RawTurtle.teleport turtle.TNavigator.teleport turtle.TPen.teleport