Files
typeshed/stdlib/@python2/mmap.pyi
Charly C 389b92cb04 fix the stub files for the stdlib mmap module (#5705)
In Python 3:
- The `mmap` type is `Iterable[int]`, not `Iterable[bytes]`.
- The `read_byte` method returns an `int`, and the `write_byte` method only accepts an `int` as its first and only argument.
- The `__setitem__` method accepts any `ReadableBuffer` object, not just `bytes`.

In both Python 2 and 3:
- The `__delitem__` method always raises a `TypeError`, so the proper return type is `NoReturn`.
- The `mmap` type isn't generic, so I've simplified the stubs by removing the unnecessary `_mmap` class.
2021-06-29 08:01:32 -07:00

54 lines
1.8 KiB
Python

import sys
from typing import NoReturn, Optional, Sequence, Union
ACCESS_DEFAULT: int
ACCESS_READ: int
ACCESS_WRITE: int
ACCESS_COPY: int
ALLOCATIONGRANULARITY: int
if sys.platform == "linux":
MAP_DENYWRITE: int
MAP_EXECUTABLE: int
if sys.platform != "win32":
MAP_ANON: int
MAP_ANONYMOUS: int
MAP_PRIVATE: int
MAP_SHARED: int
PROT_EXEC: int
PROT_READ: int
PROT_WRITE: int
PAGESIZE: int
class mmap(Sequence[bytes]):
if sys.platform == "win32":
def __init__(
self, fileno: int, length: int, tagname: Optional[str] = ..., access: int = ..., offset: int = ...
) -> None: ...
else:
def __init__(
self, fileno: int, length: int, flags: int = ..., prot: int = ..., access: int = ..., offset: int = ...
) -> None: ...
def close(self) -> None: ...
def flush(self, offset: int = ..., size: int = ...) -> int: ...
def move(self, dest: int, src: int, count: int) -> None: ...
def read_byte(self) -> bytes: ...
def readline(self) -> bytes: ...
def resize(self, newsize: int) -> None: ...
def seek(self, pos: int, whence: int = ...) -> None: ...
def size(self) -> int: ...
def tell(self) -> int: ...
def write_byte(self, byte: bytes) -> None: ...
def __len__(self) -> int: ...
def find(self, string: bytes, start: int = ..., end: int = ...) -> int: ...
def rfind(self, string: bytes, start: int = ..., stop: int = ...) -> int: ...
def read(self, num: int) -> bytes: ...
def write(self, string: bytes) -> None: ...
def __getitem__(self, index: Union[int, slice]) -> bytes: ...
def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ...
def __delitem__(self, index: Union[int, slice]) -> NoReturn: ...
def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ...