Enable mmap on PyPy (#8840)

This commit is contained in:
Andrew Murray 2025-03-30 03:36:36 +11:00 committed by GitHub
parent 25653d2f87
commit bce83ac800
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View File

@ -621,6 +621,8 @@ class Image:
more information.
"""
if getattr(self, "map", None):
if sys.platform == "win32" and hasattr(sys, "pypy_version_info"):
self.map.close()
self.map: mmap.mmap | None = None
# Instead of simply setting to None, we're setting up a

View File

@ -34,7 +34,6 @@ import itertools
import logging
import os
import struct
import sys
from typing import IO, TYPE_CHECKING, Any, NamedTuple, cast
from . import ExifTags, Image
@ -278,8 +277,6 @@ class ImageFile(Image.Image):
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