urllib2.build_open() accepts instances and classes (#2284)

<https://docs.python.org/2/library/urllib2.html#urllib2.build_opener>
> handlers can be either instances of BaseHandler, or subclasses of
> BaseHandler (in which case it must be possible to call the constructor
> without any parameters).
This commit is contained in:
Philipp Hahn
2018-06-28 05:13:46 +02:00
committed by Jelle Zijlstra
parent 4e3b8f7e15
commit ee07115c96

View File

@@ -1,6 +1,6 @@
import ssl
from typing import Any, AnyStr, Dict, List, Union, Optional, Mapping, Callable, Sequence, Tuple
from typing import Any, AnyStr, Dict, List, Union, Optional, Mapping, Callable, Sequence, Tuple, Type
from urllib import addinfourl
from httplib import HTTPResponse
@@ -53,7 +53,7 @@ def urlopen(url: Union[Request, _string], data: Optional[_string] = ..., timeout
cafile: Optional[_string] = ..., capath: Optional[_string] = ..., cadefault: bool = ...,
context: Optional[ssl.SSLContext] = ...): ...
def install_opener(opener: OpenerDirector) -> None: ...
def build_opener(*handlers: BaseHandler) -> OpenerDirector: ...
def build_opener(*handlers: Union[BaseHandler, Type[BaseHandler]]) -> OpenerDirector: ...
class BaseHandler:
handler_order = ... # type: int