From 19740f685a1bc7d958e066aee521774fdec28bb1 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Sun, 11 Jan 2026 20:21:28 +0400 Subject: [PATCH 1/3] [urllib] Deprecate cafile, capath, cadefault parameters Source: https://github.com/python/cpython/pull/105384/ --- stdlib/urllib/request.pyi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index a00e7406ee1e..a9ad70575bf5 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -65,13 +65,22 @@ if sys.version_info >= (3, 13): ) -> _UrlopenRet: ... else: + @overload + def urlopen( + url: str | Request, data: _DataType | None = None, timeout: float | None = ..., *, 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: str | None = None, - capath: str | None = None, + cafile: StrOrBytesPath | None = None, + capath: StrOrBytesPath | None = None, cadefault: bool = False, context: ssl.SSLContext | None = None, ) -> _UrlopenRet: ... From 57c2b2c5e9b486c66d02caf2df307bd003080ed4 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Sun, 11 Jan 2026 20:26:41 +0400 Subject: [PATCH 2/3] reflect the impossibility of passing `context` and `cafile` at once --- stdlib/urllib/request.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index a9ad70575bf5..8a131347a5a8 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -82,7 +82,7 @@ else: cafile: StrOrBytesPath | None = None, capath: StrOrBytesPath | None = None, cadefault: bool = False, - context: ssl.SSLContext | None = None, + context: None = None, ) -> _UrlopenRet: ... def install_opener(opener: OpenerDirector) -> None: ... From 361db11cd0ed09bf1c6f1b8c89db634914cb69ac Mon Sep 17 00:00:00 2001 From: donbarbos Date: Mon, 12 Jan 2026 00:24:39 +0400 Subject: [PATCH 3/3] last fix --- stdlib/urllib/request.pyi | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 8a131347a5a8..f7e1f278d3e6 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -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 @@ -67,7 +67,14 @@ if sys.version_info >= (3, 13): else: @overload def urlopen( - url: str | Request, data: _DataType | None = None, timeout: float | None = ..., *, context: ssl.SSLContext | None = None + url: str | Request, + data: _DataType | None = None, + timeout: float | None = ..., + *, + cafile: None = None, + capath: None = None, + cadefault: Literal[False] = False, + context: ssl.SSLContext | None = None, ) -> _UrlopenRet: ... @overload @deprecated(