From 408cec404a57191d423f93160b63ab121c650127 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 2 May 2026 15:40:47 +1000 Subject: [PATCH] Correct type when using PngStream with a context manager --- src/PIL/PngImagePlugin.py | 3 +++ 1 file changed, 3 insertions(+) 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: