diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 1330c48e6..058fb831c 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -400,6 +400,9 @@ class PngStream(ChunkStream): self.text_memory = 0 + def __enter__(self) -> PngStream: + return self + def check_text_memory(self, chunklen: int) -> None: self.text_memory += chunklen if self.text_memory > MAX_TEXT_MEMORY: