Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected pathlib.Path detection when saving #5633

Merged
merged 1 commit into from Aug 6, 2021

Conversation

radarhere
Copy link
Member

Resolves #5632

As #3825 did for open(), this fixes detecting pathlib.Path in save().

Pillow/src/PIL/Image.py

Lines 2183 to 2188 in 68c5f2d

if isPath(fp):
filename = fp
open_fp = True
elif isinstance(fp, Path):
filename = str(fp)
open_fp = True

The above code will never execute the second block, because isPath returns true for Path instances.

def isPath(f):
return isinstance(f, (bytes, str, Path))

So this PR swaps the order.

@radarhere radarhere added the Bug Any unexpected behavior, until confirmed feature. label Jul 24, 2021
@hugovk hugovk merged commit 2e5ce83 into python-pillow:master Aug 6, 2021
@radarhere radarhere deleted the save_path branch August 6, 2021 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saving an image with JPEG2000 format doesn't accept Path object
2 participants