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

Interoperability with other path libraries (PEP 519) #24

Open
levic opened this issue Sep 7, 2017 · 3 comments
Open

Interoperability with other path libraries (PEP 519) #24

levic opened this issue Sep 7, 2017 · 3 comments

Comments

@levic
Copy link

levic commented Sep 7, 2017

Python 3.6 introduced PEP 519

Short summary in python 3.6 here: https://docs.python.org/3/whatsnew/3.6.html#pep-519-adding-a-file-system-path-protocol

import unipath
import pathlib

print(unipath.Path('a', 'b', pathlib.Path('c', 'd')))

Presently the above code would fail with TypeError: arguments must be str, unicode, list, int, long, or Path

If os.fspath is present it could be used to convert a path-like object into a string.

(unipath.Path could also be changed to implement __fspath__ but since str is already an ancestor class I'm not sure that what it would achieve)

@levic
Copy link
Author

levic commented Sep 7, 2017

(Note that pathlib.Path('a', 'b', unipath.Path('c', 'd')) already works because str is an ancestor of unipath.Path)

@levic
Copy link
Author

levic commented Sep 7, 2017

@mikeorr Given that you've stated Unipath is in maintenance mode, would you accept a patch if I implemented this?

@mikeorr
Copy link
Owner

mikeorr commented Sep 7, 2017

Yes, that's a good idea. I've read about .fspath but it never occurred to me that this related to Unipath. I'm still transitioning from Python 2 to 3 and I'm waiting until I'm fully on Python 3.6 before using 'pathlib' where the stdlib functions support it because it's too much to manage a Python 2/3 codebase at the same time as a must-str()-pathlib codebase: it cancels out most of the benefits of using 'pathlib' in the first place.

Also if you have any ideas for #23 that would be helpful. I have no idea what's wrong or what to do about it.

@levic levic mentioned this issue Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants