mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-24 16:24:11 +03:00
Merge pull request #2110 from patricksnape/allow_pathlib_py2
Allow pathlib.Path in Image.open on Python 2.7
This commit is contained in:
commit
bc354d10c2
12
PIL/Image.py
12
PIL/Image.py
|
@ -2279,10 +2279,14 @@ def open(fp, mode="r"):
|
|||
filename = ""
|
||||
if isPath(fp):
|
||||
filename = fp
|
||||
elif sys.version_info >= (3, 4):
|
||||
from pathlib import Path
|
||||
if isinstance(fp, Path):
|
||||
filename = str(fp.resolve())
|
||||
else:
|
||||
try:
|
||||
from pathlib import Path
|
||||
if isinstance(fp, Path):
|
||||
filename = str(fp.resolve())
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
if filename:
|
||||
fp = builtins.open(filename, "rb")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user