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 @@ 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