Skip to content

Commit c96d8dd

Browse files
authored
[urllib] Deprecate cafile, capath, cadefault parameters (#15260)
1 parent a679bdc commit c96d8dd

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

stdlib/urllib/request.pyi

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from email.message import Message
66
from http.client import HTTPConnection, HTTPMessage, HTTPResponse
77
from http.cookiejar import CookieJar
88
from re import Pattern
9-
from typing import IO, Any, ClassVar, NoReturn, Protocol, TypeVar, overload, type_check_only
9+
from typing import IO, Any, ClassVar, Literal, NoReturn, Protocol, TypeVar, overload, type_check_only
1010
from typing_extensions import TypeAlias, deprecated
1111
from urllib.error import HTTPError as HTTPError
1212
from urllib.response import addclosehook, addinfourl
@@ -65,16 +65,32 @@ if sys.version_info >= (3, 13):
6565
) -> _UrlopenRet: ...
6666

6767
else:
68+
@overload
6869
def urlopen(
6970
url: str | Request,
7071
data: _DataType | None = None,
7172
timeout: float | None = ...,
7273
*,
73-
cafile: str | None = None,
74-
capath: str | None = None,
75-
cadefault: bool = False,
74+
cafile: None = None,
75+
capath: None = None,
76+
cadefault: Literal[False] = False,
7677
context: ssl.SSLContext | None = None,
7778
) -> _UrlopenRet: ...
79+
@overload
80+
@deprecated(
81+
"The `cafile`, `capath`, `cadefault` parameters are deprecated since Python 3.6; "
82+
"removed in Python 3.13. Use `context` parameter instead."
83+
)
84+
def urlopen(
85+
url: str | Request,
86+
data: _DataType | None = None,
87+
timeout: float | None = ...,
88+
*,
89+
cafile: StrOrBytesPath | None = None,
90+
capath: StrOrBytesPath | None = None,
91+
cadefault: bool = False,
92+
context: None = None,
93+
) -> _UrlopenRet: ...
7894

7995
def install_opener(opener: OpenerDirector) -> None: ...
8096
def build_opener(*handlers: BaseHandler | Callable[[], BaseHandler]) -> OpenerDirector: ...

0 commit comments

Comments
 (0)