Skip to content

combine removes filename whitespace when the base is empty #603

Open

Description

@xiehuanyi

fs.path.combine() removes leading whitespace from a valid relative filename when the base is empty:

from fs.path import combine

combine("", " report.txt")  # actual: "report.txt"; expected: " report.txt"
combine("folder", " report.txt")  # "folder/ report.txt"

The same issue affects MemoryFS.walk.files(path=""): a file stored as " report.txt" is returned as "report.txt", so the returned path no longer addresses the file.

The empty-base branch calls str.lstrip() without a character argument. Returning the supplied path unchanged preserves its whitespace and the existing leading-slash behavior. I have a small fix with path and MemoryFS traversal regressions ready. Both regressions fail against upstream; all 2656 project tests pass with the fix on Python 3.10.20 (26 existing skips).

Prepared with AI assistance and independently reviewed before submission.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions