Skip to content
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 converting std::path::{Path, PathBuf} to pathlib.Path #4907

Open
Ravencentric opened this issue Feb 13, 2025 · 0 comments · May be fixed by #4925
Open

Support converting std::path::{Path, PathBuf} to pathlib.Path #4907

Ravencentric opened this issue Feb 13, 2025 · 0 comments · May be fixed by #4925

Comments

@Ravencentric
Copy link

For example, take this very simple rust function. Calling it from python will result in PathBuf getting converted to builtins.str instead of pathlib.Path. My feature request is that it should instead convert to pathlib.Path.

fn get_parent_directory(path: PathBuf) -> PyResult<PathBuf> {
    let dir = match path.as_ref().parent() {
        Some(parent) if parent == Path::new("") => Path::new("."),
        Some(parent) => parent,
        None => Path::new("."),
        };

    let dir = dunce::canonicalize(dir).map_err(|e| PyOSError::new_err(e.to_string()))?;
    Ok(dir)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant