From a06c847ace000c0fbafc4627ed455c7bf945d823 Mon Sep 17 00:00:00 2001 From: Nilesh Patil <128893479+nileshpatil6@users.noreply.github.com> Date: Sat, 16 May 2026 20:07:54 +0530 Subject: [PATCH] fix: silence ENOTDIR in Config.from_file() to match from_pyfile() from_pyfile() already silences errno.ENOTDIR when silent=True, but from_file() was missing it. Both methods should behave consistently when a path component is a regular file rather than a directory. Fixes #6023 --- src/flask/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flask/config.py b/src/flask/config.py index 34ef1a57..9e37f2bd 100644 --- a/src/flask/config.py +++ b/src/flask/config.py @@ -293,7 +293,7 @@ class Config(dict): # type: ignore[type-arg] with open(filename, "r" if text else "rb") as f: obj = load(f) except OSError as e: - if silent and e.errno in (errno.ENOENT, errno.EISDIR): + if silent and e.errno in (errno.ENOENT, errno.EISDIR, errno.ENOTDIR): return False e.strerror = f"Unable to load configuration file ({e.strerror})"