Skip to content

Delegate local file capabilities to the underlying handle - #2220

Open
PDGGK wants to merge 1 commit into
fsspec:masterfrom
PDGGK:fix/local-file-capabilities
Open

PDGGK wants to merge 1 commit into
fsspec:masterfrom
PDGGK:fix/local-file-capabilities

Conversation

@PDGGK

@PDGGK PDGGK commented Oct 2, 2026

Copy link
Copy Markdown

Problem

A local text update opened through fsspec.open(path, "r+", encoding="utf-8") can raise io.UnsupportedOperation: not writable, although the underlying r+b file supports writes. The filesystem("file").open route has the same result. Write-only local streams also report readable=True.

The capability methods introduced in #589 use mode-string heuristics. TextIOWrapper relies on those reported capabilities, so an incorrect result prevents otherwise supported updates.

Change

Delegate LocalFileOpener.readable() and writable() to the underlying file object, as the other I/O operations already do. Add capability, public text-update, closed-handle, pickle and compression regression tests, plus a changelog entry.

The change is limited to these two capability expressions. It does not change mode parsing, stream ownership, transactions or remote filesystems, or add support for compressed update modes.

Validation

Tested locally on Linux with Python 3.12.14 only:

  • Local/core/spec/compression/API/cached/dirfs/memory suites: 896 passed, 70 skipped, 2 xfailed.
  • Final regression selection: 20 passed. Reverting only production code gives 13 failures and 7 passes with the same tests.
  • An additional 45-case check covers public opener routes, binary/text modes, persisted bytes against builtin open, pickle, closing behavior, and gzip/bz2/xz.
  • Applicable changed-file pre-commit hooks and whitespace checks pass.

The skips include unavailable optional dependencies and Windows-specific checks. The full upstream Python/OS matrix, remote integrations and downstream CI were not run locally. A multiprocessing/fork deprecation warning remains in the tested suite.

@PDGGK
PDGGK force-pushed the fix/local-file-capabilities branch from 75f9a14 to 6780e44 Compare October 3, 2026 06:51
@PDGGK
PDGGK marked this pull request as ready for review October 3, 2026 06:52
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