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.
This commit is contained in:
Michael Lee
2018-08-08 17:05:35 -07:00
committed by Jelle Zijlstra
parent 5b2c8dc883
commit bc8d68cd34
2 changed files with 2 additions and 0 deletions

View File

@@ -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

View File

@@ -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): ...