Make urllib2.urlopen return a non-optional addinfourl (#2821)

This is technically wrong. The documentation states that:
"Note that None may be returned if no handler handles the request
(though the default installed global OpenerDirector uses
UnknownHandler to ensure this never happens)."

This is super marginal and making it optional causes a few dozen
errors in an internal dropbox code base.
This commit is contained in:
Michael J. Sullivan
2019-03-01 16:08:26 -08:00
committed by GitHub
parent 14e387b6fd
commit f569957bbe

View File

@@ -52,9 +52,11 @@ class OpenerDirector(object):
def open(self, fullurl: Union[Request, _string], data: Optional[_string] = ..., timeout: Optional[float] = ...) -> Optional[addinfourl]: ...
def error(self, proto: _string, *args: Any): ...
# Note that this type is somewhat a lie. The return *can* be None if
# a custom opener has been installed that fails to handle the request.
def urlopen(url: Union[Request, _string], data: Optional[_string] = ..., timeout: Optional[float] = ...,
cafile: Optional[_string] = ..., capath: Optional[_string] = ..., cadefault: bool = ...,
context: Optional[ssl.SSLContext] = ...) -> Optional[addinfourl]: ...
context: Optional[ssl.SSLContext] = ...) -> addinfourl: ...
def install_opener(opener: OpenerDirector) -> None: ...
def build_opener(*handlers: Union[BaseHandler, Type[BaseHandler]]) -> OpenerDirector: ...