mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Merge pull request #3216 from radarhere/mmap
Changed mmap file pointer to use context manager
This commit is contained in:
commit
cebcc06a1b
|
@ -174,9 +174,8 @@ class ImageFile(Image.Image):
|
|||
else:
|
||||
# use mmap, if possible
|
||||
import mmap
|
||||
fp = open(self.filename, "r")
|
||||
size = os.path.getsize(self.filename)
|
||||
self.map = mmap.mmap(fp.fileno(), size, access=mmap.ACCESS_READ)
|
||||
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
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user