[stdlib] Deprecate keyfile, certfile and check_hostname parameters (#15259)

This commit is contained in:
Semyon Moroz
2026-01-11 23:31:03 +01:00
committed by GitHub
parent 3593e35df4
commit a679bdc438
5 changed files with 125 additions and 28 deletions
+21 -7
View File
@@ -1,7 +1,7 @@
import subprocess
import sys
import time
from _typeshed import ReadableBuffer, SizedBuffer, Unused
from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath, Unused
from builtins import list as _list # conflicts with a method named "list"
from collections.abc import Callable, Generator
from datetime import datetime
@@ -9,7 +9,7 @@ from re import Pattern
from socket import socket as _socket
from ssl import SSLContext, SSLSocket
from types import TracebackType
from typing import IO, Any, Literal, SupportsAbs, SupportsInt
from typing import IO, Any, Literal, SupportsAbs, SupportsInt, overload
from typing_extensions import Self, TypeAlias, deprecated
__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"]
@@ -120,23 +120,37 @@ if sys.version_info >= (3, 14):
def burst(self, interval: float = 0.1) -> Generator[tuple[str, float | None]]: ...
class IMAP4_SSL(IMAP4):
if sys.version_info < (3, 12):
keyfile: str
certfile: str
if sys.version_info >= (3, 12):
def __init__(
self, host: str = "", port: int = 993, *, ssl_context: SSLContext | None = None, timeout: float | None = None
) -> None: ...
else:
@overload
def __init__(
self,
host: str = "",
port: int = 993,
keyfile: str | None = None,
certfile: str | None = None,
keyfile: None = None,
certfile: None = None,
ssl_context: SSLContext | None = None,
timeout: float | None = None,
) -> None: ...
@overload
@deprecated(
"The `keyfile`, `certfile` parameters are deprecated since Python 3.6; "
"removed in Python 3.12. Use `ssl_context` parameter instead."
)
def __init__(
self,
host: str = "",
port: int = 993,
keyfile: StrOrBytesPath | None = None,
certfile: StrOrBytesPath | None = None,
ssl_context: None = None,
timeout: float | None = None,
) -> None: ...
keyfile: StrOrBytesPath | None
certfile: StrOrBytesPath | None
sslobj: SSLSocket
if sys.version_info >= (3, 14):
@property