-
Notifications
You must be signed in to change notification settings - Fork 30
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
Support os.PathLike
for paths and filenames.
#150
Conversation
0570108
to
713252f
Compare
Ok, I've updated this to use a converter to |
Python/PyPlasma.cpp
Outdated
@@ -44,6 +44,25 @@ ST::string PyAnyString_AsSTString(PyObject* str) | |||
} | |||
} | |||
|
|||
int PyAnyString_PathDecoder(PyObject* obj, ST::string* str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the second argument will need to be void*
to comply with Python's API...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It compiles and works on my testing in Windows. That's probably because Python's doing crazy va arg magic where type safety becomes a figment of the imagination. I can change it if you prefer, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and changed the second argument to void*
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think newer versions of GCC (GCC 8?) will complain about it (our CI is only building with GCC 5, so it doesn't trigger). So thanks for updating it.
This changeset adds support for the
os.PathLike
protocol added in Python 3.6 for any properties or function arguments that expect anything resembling a path or a filename. This allows us to passpathlib.Path
objects seemlessly to libHSPlasma in Python 3.6+. CPython seems to usePyUnicode_FSDecoder
instead of manually calling the__fspath__
method, so that is the approach I took. Unfortunately, In lower versioned Python 3.5 and lower, it is still required to convert path objects to their string representations before passing them to libHSPlasma.This closes #148