From 76532808f4b350741669e776598f338e4d2e5a96 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 10 Dec 2025 15:26:14 +0200 Subject: [PATCH] Fix ResourceWarning in selftest.py --- selftest.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/selftest.py b/selftest.py index e9b5689a0..c484d4e2d 100755 --- a/selftest.py +++ b/selftest.py @@ -40,12 +40,14 @@ def testimage() -> None: >>> with Image.open("Tests/images/hopper.gif") as im: ... _info(im) ('GIF', 'P', (128, 128)) - >>> _info(Image.open("Tests/images/hopper.ppm")) + >>> with Image.open("Tests/images/hopper.ppm") as im: + ... _info(im) ('PPM', 'RGB', (128, 128)) >>> try: - ... _info(Image.open("Tests/images/hopper.jpg")) + ... with Image.open("Tests/images/hopper.jpg") as im: + ... _info(im) ... except OSError as v: - ... print(v) + ... print(v) ('JPEG', 'RGB', (128, 128)) PIL doesn't actually load the image data until it's needed,