From a8326def098754bfbd42bc19e7d382e99af24d54 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Wed, 8 Aug 2018 15:08:59 -0700 Subject: [PATCH] Add constructor for HTTPError in urllib2/urllib.error It seems that code using HTTPError previously worked by accident because we used to accept arbitrary keyword arguments when instantiating BaseException, or any subclass of BaseException (see https://github.com/python/typeshed/pull/2348). This commit adds in the correct constructor (which also lets the user specify the arguments in keyword-argument form). Note: I'm not very familiar with the urllib libraries, so I opted to just add the signature and leave it up to somebody else to fill in the types. --- stdlib/2/urllib2.pyi | 1 + stdlib/3/urllib/error.pyi | 1 + 2 files changed, 2 insertions(+) diff --git a/stdlib/2/urllib2.pyi b/stdlib/2/urllib2.pyi index e15289738033..f71a08b9c9fe 100644 --- a/stdlib/2/urllib2.pyi +++ b/stdlib/2/urllib2.pyi @@ -12,6 +12,7 @@ class URLError(IOError): class HTTPError(URLError, addinfourl): code = ... # type: int headers = ... # type: Dict[str, str] + def __init__(self, url, code, msg, hdrs, fp) -> None: ... class Request(object): host = ... # type: str diff --git a/stdlib/3/urllib/error.pyi b/stdlib/3/urllib/error.pyi index a29347c19d27..6e3d6a58ff2b 100644 --- a/stdlib/3/urllib/error.pyi +++ b/stdlib/3/urllib/error.pyi @@ -8,4 +8,5 @@ class URLError(IOError): class HTTPError(URLError, addinfourl): code = ... # type: int headers = ... # type: Dict[str, str] + def __init__(self, url, code, msg, hdrs, fp) -> None: ... class ContentTooShortError(URLError): ...