From bc8d68cd34a5657eecea0045c1e66c241cdef192 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Wed, 8 Aug 2018 17:05:35 -0700 Subject: [PATCH] Add constructor for HTTPError in urllib2/urllib.error (#2373) 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 e15289738..f71a08b9c 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 a29347c19..6e3d6a58f 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): ...