diff --git a/storages/utils.py b/storages/utils.py index 1a9753e1..a44c524c 100644 --- a/storages/utils.py +++ b/storages/utils.py @@ -34,9 +34,9 @@ def clean_name(name): Normalize the name. Includes cleaning up Windows style paths, ensuring an ending trailing slash, - and coercing from pathlib.Path. + and coercing from pathlib.PurePath. """ - if isinstance(name, pathlib.Path): + if isinstance(name, pathlib.PurePath): name = str(name) # Normalize Windows style paths diff --git a/tests/test_utils.py b/tests/test_utils.py index 25279503..b6082765 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -26,6 +26,9 @@ def test_clean_name_pathlib(self): path = pathlib.Path("path/to/anywhere") self.assertEqual(utils.clean_name(path), "path/to/anywhere") + path = pathlib.PurePath("path/to/anywhere") + self.assertEqual(utils.clean_name(path), "path/to/anywhere") + def test_clean_name_normalize(self): """ Test the normalization of clean_name