-
Notifications
You must be signed in to change notification settings - Fork 622
Open
Labels
bindings/pythonenhancementNew feature or requestNew feature or requestreleases-note/featThe PR implements a new feature or has a title that begins with "feat"The PR implements a new feature or has a title that begins with "feat"services/fs
Description
Feature Description
The following fails:
from opendal import Operator
from pathlib import Path
import os
os.makedirs("foo", exist_ok=True)
file = Path("foo", "bar.txt")
file.touch()
file.write_text("baz")
op = Operator("fs", root=Path("foo").resolve())
for file in op.list("/"):
print(file.metadata)
with:
thread '<unnamed>' panicked at src/operator.rs:76:22:
must be valid hashmap: PyErr { type: <class 'TypeError'>, value: TypeError("'PosixPath' object cannot be converted to 'PyString'"), traceback: None }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/Users/jayceslesar/projects/fileparty/asdf.py", line 13, in <module>
op = Operator("fs", root=Path("foo").resolve())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: must be valid hashmap: PyErr { type: <class 'TypeError'>, value: TypeError("'PosixPath' object cannot be converted to 'PyString'"), traceback: None }
Problem and Solution
All other PathBuf
arguments take Path
objects so IMO it makes sense for root
to also accept one.
Additional Context
Simply wrapping the Path
object in a str
call works, as does calling .name
but it makes sense to allow a Path
object
Are you willing to contribute to the development of this feature?
- Yes, I am willing to contribute to the development of this feature.
dosubot
Metadata
Metadata
Assignees
Labels
bindings/pythonenhancementNew feature or requestNew feature or requestreleases-note/featThe PR implements a new feature or has a title that begins with "feat"The PR implements a new feature or has a title that begins with "feat"services/fs