Support for pathlib.Path in datasets 2.19.0
NONE
+1 I just noticed this when I tried to update `datasets` today.
2024-08-22T18:45:55Z
https://github.com/huggingface/datasets/issues/6935#issuecomment-2305415431
https://api.github.com/repos/huggingface/datasets/issues/6935
IC_kwDODunzps6JadkH
https://api.github.com/repos/huggingface/datasets/issues/comments/2305415431/reactions
2024-08-22T18:45:55Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2305415431
https://avatars.githubusercontent.com/u/641648?v=4
https://api.github.com/users/belambert/events{/privacy}
https://api.github.com/users/belambert/followers
https://api.github.com/users/belambert/following{/other_user}
https://api.github.com/users/belambert/gists{/gist_id}
https://github.com/belambert
belambert
MDQ6VXNlcjY0MTY0OA==
https://api.github.com/users/belambert/orgs
https://api.github.com/users/belambert/received_events
https://api.github.com/users/belambert/repos
https://api.github.com/users/belambert/starred{/owner}{/repo}
https://api.github.com/users/belambert/subscriptions
User
https://api.github.com/users/belambert
public
NONE
The same issue, I also get error.
2025-01-14T11:50:21Z
https://github.com/huggingface/datasets/issues/6935#issuecomment-2589711615
https://api.github.com/repos/huggingface/datasets/issues/6935
IC_kwDODunzps6aW9z_
https://api.github.com/repos/huggingface/datasets/issues/comments/2589711615/reactions
2025-01-14T11:50:21Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2589711615
https://avatars.githubusercontent.com/u/20803206?v=4
https://api.github.com/users/lyriccoder/events{/privacy}
https://api.github.com/users/lyriccoder/followers
https://api.github.com/users/lyriccoder/following{/other_user}
https://api.github.com/users/lyriccoder/gists{/gist_id}
https://github.com/lyriccoder
lyriccoder
MDQ6VXNlcjIwODAzMjA2
https://api.github.com/users/lyriccoder/orgs
https://api.github.com/users/lyriccoder/received_events
https://api.github.com/users/lyriccoder/repos
https://api.github.com/users/lyriccoder/starred{/owner}{/repo}
https://api.github.com/users/lyriccoder/subscriptions
User
https://api.github.com/users/lyriccoder
public
### Describe the bug

After the recent update of `datasets`, Dataset.save_to_disk does not accept a pathlib.Path anymore. It was supported in 2.18.0 and previous versions. Is this intentional? Was it supported before only because of a Python dusk-typing miracle?

### Steps to reproduce the bug

```
from datasets import Dataset
import pathlib

path = pathlib.Path("./my_out_path")
Dataset.from_dict(
    {"text": ["hello world"], "label": [777], "split": ["train"]}
.save_to_disk(path)
```
This results in an error when using datasets 2.19:
```
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/Users/jb/scratch/venv/lib/python3.11/site-packages/datasets/arrow_dataset.py", line 1515, in save_to_disk
    fs, _ = url_to_fs(dataset_path, **(storage_options or {}))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jb/scratch/venv/lib/python3.11/site-packages/fsspec/core.py", line 383, in url_to_fs
    chain = _un_chain(url, kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jb/scratch/venv/lib/python3.11/site-packages/fsspec/core.py", line 323, in _un_chain
    if "::" in path
       ^^^^^^^^^^^^
TypeError: argument of type 'PosixPath' is not iterable
```

Converting to str works, however.
```
Dataset.from_dict(
     {"text": ["hello world"], "label": [777], "split": ["train"]}
).save_to_disk(str(path))
```

### Expected behavior

My dataset gets saved to disk without an error.

### Environment info

aiohttp==3.9.5
aiosignal==1.3.1
attrs==23.2.0
certifi==2024.2.2
charset-normalizer==3.3.2
datasets==2.19.0
dill==0.3.8
filelock==3.14.0
frozenlist==1.4.1
fsspec==2024.3.1
huggingface-hub==0.23.2
idna==3.7
multidict==6.0.5
multiprocess==0.70.16
numpy==1.26.4
packaging==24.0
pandas==2.2.2
pyarrow==16.1.0
pyarrow-hotfix==0.6
python-dateutil==2.9.0.post0
pytz==2024.1
PyYAML==6.0.1
requests==2.32.3
six==1.16.0
tqdm==4.66.4
typing_extensions==4.12.0
tzdata==2024.1
urllib3==2.2.1
xxhash==3.4.1
yarl==1.9.4