From 6afa6101919df4a0cffc9c8868d8eedd8117526f Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Tue, 11 Sep 2018 22:13:38 +1000 Subject: [PATCH] memoryview is a context manager (#2442) Since Python 3.2, __enter__ returns self and __exit__ calls self.release() --- stdlib/3/builtins.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 78c598592..23fe1e8b4 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -495,6 +495,8 @@ class memoryview(Sized, Container[int]): ndim = ... # type: int def __init__(self, obj: Union[bytes, bytearray, memoryview]) -> None: ... + def __enter__(self) -> memoryview: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ... @overload def __getitem__(self, i: int) -> int: ...