-
Notifications
You must be signed in to change notification settings - Fork 806
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
Convert PathBuf
& Path
into python pathlib.Path
instead of PyString
#4925
Conversation
7a4cd73
to
5adfc6c
Compare
5adfc6c
to
fc26584
Compare
How do we handle paths that are not utf-8? I believe both Rust and Python have ways to represent these, but I think especially on the Rust side, this is considered an implementation detail and I'm not sure we can safely convert between them. |
Not a full review (yet), but I think we need to keep the current behavior for the deprecated |
We are using the |
Oh, I didn't know we had that code, that's really cool! I think my concern is moot. |
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.
A side from keeping old conversion for IntoPy
and ToPyObject
I only have a small suggestion around the tests.
src/conversions/std/path.rs
Outdated
let pystring = unsafe { | ||
ffi::PyOS_FSPath(pyobject.as_ptr()) | ||
.assume_owned_or_err(py) | ||
.unwrap() | ||
.downcast_into::<PyString>() | ||
.unwrap() | ||
}; | ||
assert_eq!(pystring.to_string_lossy(), obj.as_ref().to_string_lossy()); |
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 wonder whether it still makes sense to compare these as strings, now that we don't have a string representation on either side. Maybe we can just get rid of this intermediate check.
Instead I think we should add a new test that a PathBuf
can be extracted from both a str
and pathlib.Path
, which was removed from this test.
a3aded7
to
f73b381
Compare
f73b381
to
86388f0
Compare
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.
LGTM, thank you very much!
closes #4907