Added support for pathlib Path objects to open and save - #1372
Conversation
|
Looks good. Do we need to update the docstring or main docs anywhere? |
|
Thanks for asking the question. From what I can see, it's just the docstrings. |
Added support for pathlib Path objects to open and save
| filename = fp.name | ||
| else: | ||
| filename = "" | ||
| elif sys.version_info >= (3, 4): |
There was a problem hiding this comment.
I'm literally a year late on this, but this breaks support for passing in file objects (with a name property) in Python 3.4 and up. Previously the file name would be pulled from fp.name (assuming it was a valid path), but now because this check is in here for Python 3.4, it no longer pulls the file name. As a result, you must set the format explicitly whenever you are saving files now, as the filename will always be an empty string after this point (because a file object is not a path), which means it can't introspect the extension.
This is broken in Pillow 3.0.0 up to the latest master, and isn't documented anywhere.
Resolves #1368