Convert PathBuf & Path into python pathlib.Path instead of PyString#4925
Convert PathBuf & Path into python pathlib.Path instead of PyString#4925
PathBuf & Path into python pathlib.Path instead of PyString#4925Conversation
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. |
Icxolu
left a comment
There was a problem hiding this comment.
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.
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
Remove `PathWrapper` as it was not used and `pyo3` now directly serialize `Path` & `PathBuf` to `pathlib.Path` following PyO3/pyo3#4925
Remove `PathWrapper` as it was not used and `pyo3` now directly serialize `Path` & `PathBuf` to `pathlib.Path` following PyO3/pyo3#4925 Closes #10848
Remove `PathWrapper` as it was not used and `pyo3` now directly serialize `Path` & `PathBuf` to `pathlib.Path` following PyO3/pyo3#4925 Closes #10848
Remove `PathWrapper` as it was not used and `pyo3` now directly serialize `Path` & `PathBuf` to `pathlib.Path` following PyO3/pyo3#4925 Closes #10848
Remove `PathWrapper` as it was not used and `pyo3` now directly serialize `Path` & `PathBuf` to `pathlib.Path` following PyO3/pyo3#4925 Closes #10848
Remove `PathWrapper` as it was not used and `pyo3` now directly serialize `Path` & `PathBuf` to `pathlib.Path` following PyO3/pyo3#4925 Closes #10848
Remove `PathWrapper` as it was not used and `pyo3` now directly serialize `Path` & `PathBuf` to `pathlib.Path` following PyO3/pyo3#4925 Closes #10848
Remove `PathWrapper` as it was not used and `pyo3` now directly serialize `Path` & `PathBuf` to `pathlib.Path` following PyO3/pyo3#4925 Closes #10848
Path::into_pyobject now returns a pathlib.Path object which doesn't work as expected when added to sys.path so revert to string (see PyO3#4925). `impl FromPyObject for PyRefMut` now returns a custom error type (that doesn't impl `std::error::Error`) so map the error back the PyErr to return it (see PyO3#5413).
Path::into_pyobject now returns a pathlib.Path object which doesn't work as expected when added to sys.path so revert to string (see PyO3#4925). `impl FromPyObject for PyRefMut` now returns a custom error type (that doesn't impl `std::error::Error`) so map the error back the PyErr to return it (see PyO3#5413).
Path::into_pyobject now returns a pathlib.Path object which doesn't work as expected when added to sys.path so revert to string (see #4925). `impl FromPyObject for PyRefMut` now returns a custom error type (that doesn't impl `std::error::Error`) so map the error back the PyErr to return it (see #5413).
closes #4907