ConfigParser read() should propagate file errors when only one config file is provided
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Feature or enhancement
Proposal:
I understand the idea that when providing an iterable of files to ConfigParser.read(...) it should not fail just because one file failed, as described in the docstring:
[...] Files that cannot be opened are silently ignored; this is
designed so that you can specify an iterable of potential
configuration file locations (e.g. current directory, user's
home directory, systemwide directory), and all existing
configuration files in the iterable will be read [...]
However, I would argue that this behaviour should be changed for providing specifically one file, as if I accidentally gave a non existent path or a directory, I'd rather my script fail than silently ignore the issue and not populate the data I expect.
In this case, the method should propagate any os-file-related errors up so that it is clearly established that the one-and-only specific file you've given as an argument is non-existent or not a file. Specifically when the path provided is relative and it worked previously but something changed in the file structure during development and suddenly I receive KeyError of non existent config keys instead of direct info that the file does not exist under a/b/c path.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 ConfigParser.read 入口點開始,檢視其對檔案 iterable 的文件化行為。閱讀連結的 Python 討論,以了解尚未解決的設計取捨,然後確立提供單一檔案與多個候選檔案之間預期的區別;當該行為獲得共識,並在實作與文件中一致反映時,工作即告完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- tooling
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100