Interoperability with other path libraries (PEP 519)
levic opened this issue · 3 comments
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)
(Note that pathlib.Path('a', 'b', unipath.Path('c', 'd'))
already works because str
is an ancestor of unipath.Path
)
@mikeorr Given that you've stated Unipath is in maintenance mode, would you accept a patch if I implemented this?
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.