Skip to content

Commit bce83ac

Browse files
authored
Enable mmap on PyPy (#8840)
1 parent 25653d2 commit bce83ac

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/PIL/Image.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ def close(self) -> None:
621621
more information.
622622
"""
623623
if getattr(self, "map", None):
624+
if sys.platform == "win32" and hasattr(sys, "pypy_version_info"):
625+
self.map.close()
624626
self.map: mmap.mmap | None = None
625627

626628
# Instead of simply setting to None, we're setting up a

src/PIL/ImageFile.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import logging
3535
import os
3636
import struct
37-
import sys
3837
from typing import IO, TYPE_CHECKING, Any, NamedTuple, cast
3938

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

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

284281
readonly = 0
285282

0 commit comments

Comments
 (0)