Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@
more information.
"""
if getattr(self, "map", None):
if sys.platform == "win32" and hasattr(sys, "pypy_version_info"):
self.map.close()

Check warning on line 625 in src/PIL/Image.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/Image.py#L625

Added line #L625 was not covered by tests
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.map: mmap.mmap | None = None

# Instead of simply setting to None, we're setting up a
Expand Down
3 changes: 0 additions & 3 deletions src/PIL/ImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import logging
import os
import struct
import sys
from typing import IO, TYPE_CHECKING, Any, NamedTuple, cast

from . import ExifTags, Image
Expand Down Expand Up @@ -278,8 +277,6 @@ def load(self) -> Image.core.PixelAccess | None:

self.map: mmap.mmap | None = None
use_mmap = self.filename and len(self.tile) == 1
# As of pypy 2.1.0, memory mapping was failing here.
use_mmap = use_mmap and not hasattr(sys, "pypy_version_info")

readonly = 0

Expand Down
Loading