mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-20 10:51:15 +08:00
asynchat + asyncore: Python 3 compatibility (#1402)
Includes an update to smtpd, which uses asynchat.
This commit is contained in:
committed by
Guido van Rossum
parent
86070643ac
commit
44127444d4
@@ -6,8 +6,8 @@ from typing import Union, Tuple, Sequence
|
||||
|
||||
|
||||
class simple_producer:
|
||||
def __init__(self, data: str, buffer_size: int = ...) -> None: ...
|
||||
def more(self) -> str: ...
|
||||
def __init__(self, data: bytes, buffer_size: int = ...) -> None: ...
|
||||
def more(self) -> bytes: ...
|
||||
|
||||
class async_chat(asyncore.dispatcher):
|
||||
ac_in_buffer_size = ... # type: int
|
||||
@@ -18,12 +18,12 @@ class async_chat(asyncore.dispatcher):
|
||||
def collect_incoming_data(self, data: bytes) -> None: ...
|
||||
@abstractmethod
|
||||
def found_terminator(self) -> None: ...
|
||||
def set_terminator(self, term: Union[str, int, None]) -> None: ...
|
||||
def get_terminator(self) -> Union[str, int, None]: ...
|
||||
def set_terminator(self, term: Union[bytes, int, None]) -> None: ...
|
||||
def get_terminator(self) -> Union[bytes, int, None]: ...
|
||||
def handle_read(self) -> None: ...
|
||||
def handle_write(self) -> None: ...
|
||||
def handle_close(self) -> None: ...
|
||||
def push(self, data: str) -> None: ...
|
||||
def push(self, data: bytes) -> None: ...
|
||||
def push_with_producer(self, producer: simple_producer) -> None: ...
|
||||
def readable(self) -> bool: ...
|
||||
def writable(self) -> bool: ...
|
||||
@@ -33,9 +33,9 @@ class async_chat(asyncore.dispatcher):
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
class fifo:
|
||||
def __init__(self, list: Sequence[Union[str, simple_producer]] = ...) -> None: ...
|
||||
def __init__(self, list: Sequence[Union[bytes, simple_producer]] = ...) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def is_empty(self) -> bool: ...
|
||||
def first(self) -> str: ...
|
||||
def push(self, data: Union[str, simple_producer]) -> None: ...
|
||||
def pop(self) -> Tuple[int, str]: ...
|
||||
def first(self) -> bytes: ...
|
||||
def push(self, data: Union[bytes, simple_producer]) -> None: ...
|
||||
def pop(self) -> Tuple[int, bytes]: ...
|
||||
|
||||
@@ -47,10 +47,15 @@ class dispatcher:
|
||||
def set_reuse_addr(self) -> None: ...
|
||||
def readable(self) -> bool: ...
|
||||
def writable(self) -> bool: ...
|
||||
def listen(self, backlog: int) -> None: ...
|
||||
def bind(self, address: Union[tuple, str]) -> None: ...
|
||||
def connect(self, address: Union[tuple, str]) -> None: ...
|
||||
def accept(self) -> Optional[Tuple[socket.socket, Any]]: ...
|
||||
def recv(self, buffer_size: int) -> str: ...
|
||||
def log(self, message: Any) -> None: ...
|
||||
def send(self, data: bytes) -> int: ...
|
||||
def recv(self, buffer_size: int) -> bytes: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
def log(self, message: Any) -> None: ...
|
||||
def log_info(self, message: Any, type: str = ...) -> None: ...
|
||||
def handle_read_event(self) -> None: ...
|
||||
def handle_connect_event(self) -> None: ...
|
||||
@@ -63,46 +68,51 @@ class dispatcher:
|
||||
def handle_connect(self) -> None: ...
|
||||
def handle_accept(self) -> None: ...
|
||||
def handle_close(self) -> None: ...
|
||||
def detach(self) -> int: ...
|
||||
def fileno(self) -> int: ...
|
||||
|
||||
# return value is an address
|
||||
def getpeername(self) -> Any: ...
|
||||
def getsockname(self) -> Any: ...
|
||||
if sys.version_info < (3, 5):
|
||||
# Historically, some methods were "imported" from `self.socket` by
|
||||
# means of `__getattr__`. This was long deprecated, and as of Python
|
||||
# 3.5 has been removed; simply call the relevant methods directly on
|
||||
# self.socket if necessary.
|
||||
|
||||
@overload
|
||||
def getsockopt(self, level: int, optname: int) -> int: ...
|
||||
@overload
|
||||
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
|
||||
def detach(self) -> int: ...
|
||||
def fileno(self) -> int: ...
|
||||
|
||||
def gettimeout(self) -> float: ...
|
||||
def ioctl(self, control: object,
|
||||
option: Tuple[int, int, int]) -> None: ...
|
||||
def listen(self, backlog: int) -> None: ...
|
||||
# TODO the return value may be BinaryIO or TextIO, depending on mode
|
||||
def makefile(self, mode: str = ..., buffering: int = ...,
|
||||
encoding: str = ..., errors: str = ...,
|
||||
newline: str = ...) -> Any:
|
||||
...
|
||||
# return value is an address
|
||||
def getpeername(self) -> Any: ...
|
||||
def getsockname(self) -> Any: ...
|
||||
|
||||
# return type is an address
|
||||
def recvfrom(self, bufsize: int, flags: int = ...) -> Any: ...
|
||||
def recvfrom_into(self, buffer: str, nbytes: int, flags: int = ...) -> Any: ...
|
||||
def recv_into(self, buffer: str, nbytes: int, flags: int = ...) -> Any: ...
|
||||
def send(self, data: str, flags: int = ...) -> Optional[int]: ...
|
||||
def sendall(self, data: str, flags: int = ...) -> None: ...
|
||||
def sendto(self, data: str, address: Union[tuple, str], flags: int = ...) -> int: ...
|
||||
def setblocking(self, flag: bool) -> None: ...
|
||||
def settimeout(self, value: Union[float, None]) -> None: ...
|
||||
def setsockopt(self, level: int, optname: int, value: Union[int, str]) -> None: ...
|
||||
def shutdown(self, how: int) -> None: ...
|
||||
@overload
|
||||
def getsockopt(self, level: int, optname: int) -> int: ...
|
||||
@overload
|
||||
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
|
||||
|
||||
def gettimeout(self) -> float: ...
|
||||
def ioctl(self, control: object,
|
||||
option: Tuple[int, int, int]) -> None: ...
|
||||
# TODO the return value may be BinaryIO or TextIO, depending on mode
|
||||
def makefile(self, mode: str = ..., buffering: int = ...,
|
||||
encoding: str = ..., errors: str = ...,
|
||||
newline: str = ...) -> Any:
|
||||
...
|
||||
|
||||
# return type is an address
|
||||
def recvfrom(self, bufsize: int, flags: int = ...) -> Any: ...
|
||||
def recvfrom_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ...
|
||||
def recv_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ...
|
||||
def sendall(self, data: bytes, flags: int = ...) -> None: ...
|
||||
def sendto(self, data: bytes, address: Union[tuple, str], flags: int = ...) -> int: ...
|
||||
def setblocking(self, flag: bool) -> None: ...
|
||||
def settimeout(self, value: Union[float, None]) -> None: ...
|
||||
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
|
||||
def shutdown(self, how: int) -> None: ...
|
||||
|
||||
class dispatcher_with_send(dispatcher):
|
||||
def __init__(self, sock: socket.socket = ..., map: _maptype = ...) -> None: ...
|
||||
def initiate_send(self) -> None: ...
|
||||
def handle_write(self) -> None: ...
|
||||
# incompatible signature:
|
||||
# def send(self, data: str) -> Optional[int]: ...
|
||||
# def send(self, data: bytes) -> Optional[int]: ...
|
||||
|
||||
def compact_traceback() -> Tuple[Tuple[str, str, str], type, type, str]: ...
|
||||
def close_all(map: _maptype = ..., ignore_all: bool = ...) -> None: ...
|
||||
@@ -113,16 +123,16 @@ class file_wrapper:
|
||||
fd = ... # type: int
|
||||
|
||||
def __init__(self, fd: int) -> None: ...
|
||||
def recv(self, bufsize: int, flags: int = ...) -> str: ...
|
||||
def send(self, data: str, flags: int = ...) -> int: ...
|
||||
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
|
||||
def send(self, data: bytes, flags: int = ...) -> int: ...
|
||||
|
||||
@overload
|
||||
def getsockopt(self, level: int, optname: int) -> int: ...
|
||||
@overload
|
||||
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
|
||||
|
||||
def read(self, bufsize: int, flags: int = ...) -> str: ...
|
||||
def write(self, data: str, flags: int = ...) -> int: ...
|
||||
def read(self, bufsize: int, flags: int = ...) -> bytes: ...
|
||||
def write(self, data: bytes, flags: int = ...) -> int: ...
|
||||
|
||||
def close(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
|
||||
@@ -47,7 +47,7 @@ class SMTPChannel(asynchat.async_chat):
|
||||
map: Optional[asyncore._maptype] = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ...
|
||||
def push(self, msg: Text) -> None: ...
|
||||
def push(self, msg: bytes) -> None: ...
|
||||
def collect_incoming_data(self, data: bytes) -> None: ...
|
||||
def found_terminator(self) -> None: ...
|
||||
def smtp_HELO(self, arg: str) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user