Normalize path prefixes in shared archive ls - #2197
Merged
martindurant merged 2 commits intoSep 28, 2026
Merged
martindurant merged 2 commits into
martindurant merged 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With a ZIP archive,
fs.ls("/deeply")returns["deeply"]instead of the directory's contents, and protocol-prefixed paths such asfs.ls("zip://")orfs.ls("zip://deeply")return an empty list. The sharedAbstractArchiveFileSystem.lscompared the raw input against archive-relative entries, whileinfoandopenalready strip the protocol and leading slashes.This passes the path through
_strip_protocolat the start ofls.ZipFileSystemandLibArchiveFileSystemuse this shared method;TarFileSystemalready normalizes in its ownlsoverride.A new shared archive test checks that
/,<protocol>://and<protocol>:///prefixes give the same result as the plain path for the root, nested directories and a file, in both detail modes, and that missing paths still raiseFileNotFoundError.Testing: without the fix, the new test fails for all six ZIP cases and passes for the tar variants. With the fix,
test_archive.py,test_zip.pyandtest_tar.pypass (220 passed, 27 skipped). libarchive isn't installed locally, so its cases were skipped. Ruff 0.14.3 andgit diff --checkpass on the changed files.