Skip to content

Fix local URL downloads to file-like objects - #2230

Open
sunlishuo25 wants to merge 1 commit into
fsspec:masterfrom
sunlishuo25:fix/local-get-file-url-to-buffer
Open

sunlishuo25 wants to merge 1 commit into
fsspec:masterfrom
sunlishuo25:fix/local-get-file-url-to-buffer

Conversation

@sunlishuo25

Copy link
Copy Markdown

LocalFileSystem.get_file("file://…", buffer) raises FileNotFoundError for an existing source, while copying the same URL to a destination filename succeeds. Normalize the source before opening it in the file-like destination branch, so both file:// and local:// work with that destination type.

This uses the existing local path handling for strings and PathLike[str]. Raw bytes paths and integer file descriptors, previously accepted incidentally by the builtin open call in this branch, no longer bypass that normalizer.

Add regression coverage for both aliases, plain string/Path sources, empty/binary contents, and caller-owned output position and lifetime, plus a changelog entry.

Validation: the regression matrix had 4 failures before the fix and passes all 16 cases after it. Local/core/DirFileSystem suites: 420 passed, 27 skipped for optional dependencies/platform conditions. Additional caller/boundary checks: 19 passed. Ruff check/format and diff checks passed. Full cloud/Docker/FUSE/downstream suites and Windows/Linux execution were not run.

Developed with GPT assistance.

@sunlishuo25
sunlishuo25 marked this pull request as ready for review October 5, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant