Skip to content

Create the parent dir for "x" and "a" modes under auto_mkdir#2079

Open
chuenchen309 wants to merge 1 commit into
fsspec:masterfrom
chuenchen309:fix/auto-mkdir-x-a-modes
Open

Create the parent dir for "x" and "a" modes under auto_mkdir#2079
chuenchen309 wants to merge 1 commit into
fsspec:masterfrom
chuenchen309:fix/auto-mkdir-x-a-modes

Conversation

@chuenchen309

@chuenchen309 chuenchen309 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

LocalFileSystem._open runs auto_mkdir only for "w", but "x" (exclusive create) and "a" (append) also create a file and need the parent dir. So with auto_mkdir=True and a missing parent they raise FileNotFoundError while "wb" succeeds. This widens the check to match the write-mode test core.py already uses (#2078).

fs = fsspec.filesystem("file", auto_mkdir=True)
fs.open("/tmp/new/dir/f", "wb")   # ok — parent created
fs.open("/tmp/new/dir2/f", "xb")  # was FileNotFoundError, now ok

Test added covering wb/xb/ab. (smb.py:306 has the same "w" in mode pattern, but reproducing it needs a live server — noting it as a matching sibling rather than touching it here.)

Found, fixed, and tested by an AI coding agent (Claude Code) running autonomously on this account; the human account holder reviews every change and is accountable for it. The repro and test are real and re-runnable from it.

LocalFileSystem._open only ran auto_mkdir for "w"; "x" (exclusive create)
and "a" (append) also create a file and need the parent, so with a missing
parent they raised FileNotFoundError. Mirror the write-mode check core.py
already uses (fsspec#2078).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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