Changed mmap file pointer to use context manager

This commit is contained in:
Andrew Murray 2018-07-01 12:19:30 +10:00
parent dbf899fb78
commit c971bac651

View File

@ -174,7 +174,7 @@ class ImageFile(Image.Image):
else:
# use mmap, if possible
import mmap
fp = open(self.filename, "r")
with open(self.filename, "r") as fp:
self.map = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ)
self.im = Image.core.map_buffer(
self.map, self.size, decoder_name, extents, offset, args