Repository: fsspec/filesystem_spec

Issue:
can_be_local function not returning True in case of pathlib.Path
If a `pathlib.Path` is given to `fsspec.utils.can_be_local` `False` is returned.
I would expect `True` to be returned.

```python
from pathlib import Path
from fsspec.utils import can_be_local

p = Path("/path/to/file")

can_be_local(p)  # -> False should be True
```

I think this can be easily fixed by adding `stringify_path` to `get_protocol` before the string split: https://github.com/fsspec/filesystem_spec/blob/e20f626b87b5bb87d223495a56aefd768272a7ca/fsspec/utils.py#L438

Discussion:
martindurant: I suppose a Path is always local :)

Patch:
diff --git a/fsspec/utils.py b/fsspec/utils.py
index 34f1ad8..543bd89 100644
--- a/fsspec/utils.py
+++ b/fsspec/utils.py
@@ -436,6 +436,7 @@ def isfilelike(f: Any) -> TypeGuard[IO[bytes]]:
 
 
 def get_protocol(url: str) -> str:
+    url = stringify_path(url)
     parts = re.split(r"(\:\:|\://)", url, 1)
     if len(parts) > 1:
         return parts[0]


Test patch:
diff --git a/fsspec/tests/test_utils.py b/fsspec/tests/test_utils.py
index b5732e9..c7bad93 100644
--- a/fsspec/tests/test_utils.py
+++ b/fsspec/tests/test_utils.py
@@ -1,5 +1,6 @@
 import io
 import sys
+from pathlib import Path
 from unittest.mock import Mock
 
 import pytest
@@ -8,6 +9,7 @@ import fsspec.utils
 from fsspec.utils import (
     can_be_local,
     common_prefix,
+    get_protocol,
     infer_storage_options,
     merge_offset_ranges,
     mirror_from,
@@ -333,6 +335,24 @@ def test_log():
     assert logger.level == logging.DEBUG
 
 
+@pytest.mark.parametrize(
+    "par",
+    [
+        ("afile", "file"),
+        ("file://afile", "file"),
+        ("noproto://afile", "noproto"),
+        ("noproto::stuff", "noproto"),
+        ("simplecache::stuff", "simplecache"),
+        ("simplecache://stuff", "simplecache"),
+        ("s3://afile", "s3"),
+        (Path("afile"), "file"),
+    ],
+)
+def test_get_protocol(par):
+    url, outcome = par
+    assert get_protocol(url) == outcome
+
+
 @pytest.mark.parametrize(
     "par",
     [
@@ -342,6 +362,7 @@ def test_log():
         ("noproto::stuff", False),
         ("simplecache::stuff", True),
         ("simplecache://stuff", True),
+        (Path("afile"), True),
     ],
 )
 def test_can_local(par):