Skip to content

Commit 1af2170

Browse files
committed
Fix PyO3 0.24 API: use to_cow() instead of to_str()
1 parent 6dfbe7b commit 1af2170

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ fn extract_path(obj: &Bound<'_, PyAny>) -> PyResult<PathBuf> {
7272

7373
// Try str first
7474
if let Ok(s) = obj.downcast::<PyString>() {
75-
return validate_path(s.to_str()?);
75+
return validate_path(&s.to_cow()?);
7676
}
7777

7878
// Try os.PathLike via __fspath__
7979
if let Ok(fspath) = obj.call_method0("__fspath__") {
8080
if let Ok(s) = fspath.downcast::<PyString>() {
81-
return validate_path(s.to_str()?);
81+
return validate_path(&s.to_cow()?);
8282
}
8383
// Could be bytes, but we only support str paths
8484
if let Ok(s) = fspath.extract::<String>() {

0 commit comments

Comments
 (0)