From d9aedb7e4b5b55d80b50b1da072b49280f215f1e Mon Sep 17 00:00:00 2001 From: donBarbos Date: Tue, 24 Jun 2025 09:13:54 +0400 Subject: [PATCH 1/3] Add attributes to urllib errors --- stdlib/urllib/error.pyi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index 89cec9bf289c..9df9978e1d62 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -5,7 +5,9 @@ from urllib.response import addinfourl __all__ = ["URLError", "HTTPError", "ContentTooShortError"] class URLError(OSError): + args: tuple[str | BaseException, ...] reason: str | BaseException + filename: str def __init__(self, reason: str | BaseException, filename: str | None = None) -> None: ... class HTTPError(URLError, addinfourl): @@ -16,6 +18,9 @@ class HTTPError(URLError, addinfourl): @property def reason(self) -> str: ... # type: ignore[override] code: int + msg: str + hdrs: Message + fp: IO[bytes] def __init__(self, url: str, code: int, msg: str, hdrs: Message, fp: IO[bytes] | None) -> None: ... class ContentTooShortError(URLError): From 8b8578671414e17acbce1d5fa3abf47c63e80b5e Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Tue, 24 Jun 2025 08:08:30 +0000 Subject: [PATCH 2/3] Update stdlib/urllib/error.pyi --- stdlib/urllib/error.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index 9df9978e1d62..670ff06f83d9 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -5,7 +5,6 @@ from urllib.response import addinfourl __all__ = ["URLError", "HTTPError", "ContentTooShortError"] class URLError(OSError): - args: tuple[str | BaseException, ...] reason: str | BaseException filename: str def __init__(self, reason: str | BaseException, filename: str | None = None) -> None: ... From 09a9813a16bb5a091b854eef011f0715e93639f8 Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Mon, 7 Jul 2025 11:58:10 +0000 Subject: [PATCH 3/3] Update stdlib/urllib/error.pyi Co-authored-by: Sebastian Rittau --- stdlib/urllib/error.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index 670ff06f83d9..2173d7e6efaa 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -6,6 +6,7 @@ __all__ = ["URLError", "HTTPError", "ContentTooShortError"] class URLError(OSError): reason: str | BaseException + # The `filename` attribute only exists if it was provided to `__init__` and wasn't `None`. filename: str def __init__(self, reason: str | BaseException, filename: str | None = None) -> None: ...