[urllib] Deprecate cafile, capath, cadefault parameters (#15260)

This commit is contained in:
Semyon Moroz
2026-01-11 22:31:33 +00:00
committed by GitHub
parent a679bdc438
commit c96d8dd7f9
+20 -4
View File
@@ -6,7 +6,7 @@ from email.message import Message
from http.client import HTTPConnection, HTTPMessage, HTTPResponse
from http.cookiejar import CookieJar
from re import Pattern
from typing import IO, Any, ClassVar, NoReturn, Protocol, TypeVar, overload, type_check_only
from typing import IO, Any, ClassVar, Literal, NoReturn, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias, deprecated
from urllib.error import HTTPError as HTTPError
from urllib.response import addclosehook, addinfourl
@@ -65,16 +65,32 @@ if sys.version_info >= (3, 13):
) -> _UrlopenRet: ...
else:
@overload
def urlopen(
url: str | Request,
data: _DataType | None = None,
timeout: float | None = ...,
*,
cafile: str | None = None,
capath: str | None = None,
cadefault: bool = False,
cafile: None = None,
capath: None = None,
cadefault: Literal[False] = False,
context: ssl.SSLContext | None = None,
) -> _UrlopenRet: ...
@overload
@deprecated(
"The `cafile`, `capath`, `cadefault` parameters are deprecated since Python 3.6; "
"removed in Python 3.13. Use `context` parameter instead."
)
def urlopen(
url: str | Request,
data: _DataType | None = None,
timeout: float | None = ...,
*,
cafile: StrOrBytesPath | None = None,
capath: StrOrBytesPath | None = None,
cadefault: bool = False,
context: None = None,
) -> _UrlopenRet: ...
def install_opener(opener: OpenerDirector) -> None: ...
def build_opener(*handlers: BaseHandler | Callable[[], BaseHandler]) -> OpenerDirector: ...