Skip to content

Commit

Permalink
Fixed opening mmap image through Path on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed May 4, 2019
1 parent c15dc4d commit fffb026
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Tests/test_image.py
Expand Up @@ -76,6 +76,10 @@ def test_bad_mode(self):
@unittest.skipUnless(Image.HAS_PATHLIB, "requires pathlib/pathlib2")
def test_pathlib(self):
from PIL.Image import Path
im = Image.open(Path("Tests/images/multipage-mmap.tiff"))
self.assertEqual(im.mode, "P")
self.assertEqual(im.size, (10, 10))

im = Image.open(Path("Tests/images/hopper.jpg"))
self.assertEqual(im.mode, "RGB")
self.assertEqual(im.size, (128, 128))
Expand Down
6 changes: 3 additions & 3 deletions src/PIL/Image.py
Expand Up @@ -2643,10 +2643,10 @@ def open(fp, mode="r"):

exclusive_fp = False
filename = ""
if isPath(fp):
filename = fp
elif HAS_PATHLIB and isinstance(fp, Path):
if HAS_PATHLIB and isinstance(fp, Path):
filename = str(fp.resolve())
elif isPath(fp):
filename = fp

if filename:
fp = builtins.open(filename, "rb")
Expand Down

0 comments on commit fffb026

Please sign in to comment.