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
This commit is contained in:
parent
9fcd34c9f3
commit
a06c847ace
1 changed files with 1 additions and 1 deletions
|
|
@ -293,7 +293,7 @@ class Config(dict): # type: ignore[type-arg]
|
||||||
with open(filename, "r" if text else "rb") as f:
|
with open(filename, "r" if text else "rb") as f:
|
||||||
obj = load(f)
|
obj = load(f)
|
||||||
except OSError as e:
|
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
|
return False
|
||||||
|
|
||||||
e.strerror = f"Unable to load configuration file ({e.strerror})"
|
e.strerror = f"Unable to load configuration file ({e.strerror})"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue