summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth Morton <seth.m.morton@gmail.com>2023-01-11 08:45:17 -0800
committerGitHub <noreply@github.com>2023-01-11 08:45:17 -0800
commit34078b7fd600ca655ac10f6502eb5b430670b414 (patch)
tree2d173d5b9364b90c46230ccb7cf8063dc80c9e2a
parent837a3875e5414fecf0c87b565c8b61fde16ed016 (diff)
parent8298971836005486f50337e761fae8627a069084 (diff)
downloadnatsort-34078b7fd600ca655ac10f6502eb5b430670b414.tar.gz
Merge pull request #158 from Dobatymo/no-convert-path
os_sorted: only convert input to str if necessary
-rw-r--r--natsort/natsort.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/natsort/natsort.py b/natsort/natsort.py
index 2038f3e..3904ec5 100644
--- a/natsort/natsort.py
+++ b/natsort/natsort.py
@@ -9,6 +9,7 @@ The majority of the "work" is defined in utils.py.
import platform
from functools import partial
from operator import itemgetter
+from pathlib import PurePath
from typing import (
Any,
Callable,
@@ -669,7 +670,9 @@ def _split_apply(
) -> Iterator[str]:
if key is not None:
v = key(v)
- return utils.path_splitter(str(v))
+ if not isinstance(v, (str, PurePath)):
+ v = str(v)
+ return utils.path_splitter(v)
# Choose the implementation based on the host OS