From b9c1919e6cfb81ac6e341e00e3bf26305c72867a Mon Sep 17 00:00:00 2001 From: Yano Wilke Date: Wed, 28 Jan 2026 15:14:44 +0000 Subject: [PATCH 1/3] fix: split_path no longer removes trailing slashes --- s3fs/core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/s3fs/core.py b/s3fs/core.py index 23b2fe60..3b080e6e 100644 --- a/s3fs/core.py +++ b/s3fs/core.py @@ -470,6 +470,7 @@ def split_path(self, path) -> tuple[str, str, str | None]: >>> split_path("s3://mybucket/path/to/versioned_file?versionId=some_version_id") ['mybucket', 'path/to/versioned_file', 'some_version_id'] """ + trail = path[len(path.rstrip('/')):] path = self._strip_protocol(path) path = path.lstrip("/") if "/" not in path: @@ -477,6 +478,7 @@ def split_path(self, path) -> tuple[str, str, str | None]: else: bucket, keypart = self._find_bucket_key(path) key, _, version_id = keypart.partition("?versionId=") + key += trail # restore trailing slashes removed by AbstractFileSystem._strip_protocol return ( bucket, key, From deff693014244df23113d3e6621efe52c3986104 Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Thu, 29 Jan 2026 15:56:16 -0500 Subject: [PATCH 2/3] lint --- s3fs/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s3fs/core.py b/s3fs/core.py index 3b080e6e..62afe14d 100644 --- a/s3fs/core.py +++ b/s3fs/core.py @@ -470,7 +470,7 @@ def split_path(self, path) -> tuple[str, str, str | None]: >>> split_path("s3://mybucket/path/to/versioned_file?versionId=some_version_id") ['mybucket', 'path/to/versioned_file', 'some_version_id'] """ - trail = path[len(path.rstrip('/')):] + trail = path[len(path.rstrip("/")) :] path = self._strip_protocol(path) path = path.lstrip("/") if "/" not in path: @@ -478,7 +478,7 @@ def split_path(self, path) -> tuple[str, str, str | None]: else: bucket, keypart = self._find_bucket_key(path) key, _, version_id = keypart.partition("?versionId=") - key += trail # restore trailing slashes removed by AbstractFileSystem._strip_protocol + key += trail # restore trailing slashes removed by AbstractFileSystem._strip_protocol return ( bucket, key, From 9a46ce35fe23641df5c8a8c0c7cd9735fe9ad582 Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Tue, 27 Jan 2026 10:33:23 -0500 Subject: [PATCH 3/3] Add failing test --- s3fs/tests/test_s3fs.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/s3fs/tests/test_s3fs.py b/s3fs/tests/test_s3fs.py index 7236b319..0c12ce7e 100644 --- a/s3fs/tests/test_s3fs.py +++ b/s3fs/tests/test_s3fs.py @@ -3085,3 +3085,14 @@ async def run_program(run): aiobotocore.httpsession.AIOHTTPSession asyncio.run(run_program(True)) asyncio.run(run_program(False)) + + +def test_rm_recursive_prfix(s3): + prefix = "logs/" # must end with "/" + + # Create empty "directory" in S3 + client = get_boto3_client() + client.put_object(Bucket=test_bucket_name, Key=prefix, Body=b"") + logs_path = f"s3://{test_bucket_name}/{prefix}" + s3.rm(logs_path, recursive=True) + assert not s3.isdir(logs_path)