Skip to content

Accepting pathlib.Path as path inputs? #5968

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

Closed
michaelaye opened this issue Feb 4, 2016 · 9 comments
Closed

Accepting pathlib.Path as path inputs? #5968

michaelaye opened this issue Feb 4, 2016 · 9 comments
Labels
New feature Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@michaelaye
Copy link

pandas recently made the great effort to accept pathlib.Paths as inputs where traditionally strings would have to be provided for any path related requirements. Could this be done also for matplotlib?

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Feb 4, 2016
@WeatherGod
Copy link
Member

We don't do much in the way of path manipulations, and we do need to be
compatible with the various backends we use, so internally, I don't see us
using anything else but strings. That said, it is probably feasible to make
sure that we cast those objects into strings.

On Thu, Feb 4, 2016 at 4:42 PM, K.-Michael Aye notifications@github.com
wrote:

pandas recently made the great effort to accept pathlib.Paths as inputs
where traditionally strings would have to be provided for any path related
requirements. Could this be done also for matplotlib?


Reply to this email directly or view it on GitHub
#5968.

@michaelaye
Copy link
Author

That was all I was dreaming of so that I don't have to do the casting all the time! ;)

@WeatherGod
Copy link
Member

If you can come up with a list of functions that will need to do this
casting, that would be a huge step towards getting a PR together.

On Fri, Feb 5, 2016 at 2:55 PM, K.-Michael Aye notifications@github.com
wrote:

That was all I was dreaming of so that I don't have to do the casting all
the time! ;)


Reply to this email directly or view it on GitHub
#5968 (comment)
.

@michaelaye
Copy link
Author

I will, just not this month, which looks like the busiest of my life… ;)

On Feb 5, 2016, at 13:03, Benjamin Root notifications@github.com wrote:

If you can come up with a list of functions that will need to do this
casting, that would be a huge step towards getting a PR together.

On Fri, Feb 5, 2016 at 2:55 PM, K.-Michael Aye notifications@github.com
wrote:

That was all I was dreaming of so that I don't have to do the casting all
the time! ;)


Reply to this email directly or view it on GitHub
#5968 (comment)
.


Reply to this email directly or view it on GitHub #5968 (comment).

@aragilar
Copy link
Contributor

aragilar commented Jun 5, 2016

It's worth noting that there's now a path protocol outlined in https://www.python.org/dev/peps/pep-0519/. Using it you call os.fspath on a path to get a string/bytes view of the path, and the function is easy enough to backport (I've done this for h5py already). I'll try to submit a pull request in the next few days which adds this, should it be against master, or would this be small enough to the maintenance branches?

@tacaswell
Copy link
Member

Please target it at 2.x.

This was referenced Jul 17, 2016
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Oct 3, 2017
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jan 10, 2018
@anntzer
Copy link
Contributor

anntzer commented Jan 22, 2018

Closed by #10231.

@anntzer anntzer closed this as completed Jan 22, 2018
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
@LukeIreland1
Copy link

I think this has regressed? I'm getting ValueError: fname must be a PathLike or file handle with plt.savefig(Path("fitness/fitness1.png")) works with plt.savefig(str(Path("fitness/fitness1.png")))

@tacaswell
Copy link
Member

@LukeIreland1 Please open a new issue with your version details etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

No branches or pull requests

7 participants