Repository navigation
Fix image fmt detection for Path input. - #10754
Conversation
ce2b1fd to
19d4e8c
Compare
| @@ -1,6 +1,4 @@ | |||
| from __future__ import absolute_import, division, print_function | |||
There was a problem hiding this comment.
If you're backporting, you don't want to remove this.
19d4e8c to
8605b35
Compare
|
|
||
| if format is None: | ||
| # get format from filename, or from backend's default filetype | ||
| if isinstance(filename, getattr(os, "PathLike", ())): |
There was a problem hiding this comment.
Am I correct, that this will only fix the format detection for Python 3.6+? Since this will probably go into 2.2.x. it should also hande pre-python3.6 Path objects, i.e. check for Path instance and use filename = str(filename)?
There was a problem hiding this comment.
Also PEP-519 states
Libraries wishing to support path objects and a version of Python prior to Python 3.6 and the existence of
os.fspath()can use the idiom ofpath.__fspath__() if hasattr(path, "__fspath__") else path.
But that's more a matter of taste.
There was a problem hiding this comment.
The original PR explicitly only supported 3.6+ (see whatsnew note in https://github.com/matplotlib/matplotlib/pull/10231/files). I have no intent to reimplement the pathlike API on <3.6.
So I'll leave things as they are.
Backport PR #10754 on branch v2.2.x
PR Summary
Fixes #10753. Should probably go to 2.2.1 as the feature is basically unusable without the fix.
PR Checklist