Skip to content

Fix ENOTDIR handling in Config.from_file() with silent=True#5923

Closed
apoorvdarshan wants to merge 1 commit intopallets:mainfrom
apoorvdarshan:fix-from-file-enotdir-silent
Closed

Fix ENOTDIR handling in Config.from_file() with silent=True#5923
apoorvdarshan wants to merge 1 commit intopallets:mainfrom
apoorvdarshan:fix-from-file-enotdir-silent

Conversation

@apoorvdarshan
Copy link

Summary

  • from_pyfile() correctly suppresses errno.ENOTDIR when silent=True, but from_file() was missing it
  • This caused an OSError when a path component is a regular file instead of a directory (e.g. ~/.myapp is a file and loading ~/.myapp/config.toml)
  • One-line fix to add errno.ENOTDIR to the silent error tuple, matching from_pyfile() behavior

Test plan

  • Added test_config_enotdir_silent — creates a file where a directory is expected and confirms from_file(..., silent=True) returns False instead of raising
  • All 20 existing config tests pass

`from_pyfile()` correctly suppresses `ENOTDIR` when `silent=True`,
but `from_file()` was missing it. This caused an `OSError` when a
path component is a regular file instead of a directory (e.g.
`~/.myapp` is a file and loading `~/.myapp/config.toml`).
@ThiefMaster
Copy link
Member

ThiefMaster commented Feb 18, 2026

May I ask what made you open this PR (did an LLM tell you there is a bug? or did you actually encounter a problem yourself?), and whether you used AI for this or not?

Because we closed a similar issue as "not planned" recently, and likewise the associated PR.

@davidism davidism closed this Feb 18, 2026
@pallets pallets temporarily blocked apoorvdarshan Feb 18, 2026
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.

3 participants

Comments