configparser: reading an invalid file triggers ParsingError *and* mutations
还没有人认领这个 Issue。
评估
调研方向
从 traceback 中显示的 configparser.py 实现开始,并复现 issue 中的 read_string 示例。跟踪 _read 在引发 ParsingError 之前如何处理有效行,然后为失败情况添加或查找有针对性的测试。无效输入引发 ParsingError,且不会在 ConfigParser 对象中留下部分内容,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Bug report
A clear and concise description of what the bug is.
Include a minimal, reproducible example (https://stackoverflow.com/help/minimal-reproducible-example), if possible.
Your environment
- CPython versions tested on: 3.11.0b5
- Operating system and architecture: x86_64
here is a simple example:
>>> import configparser
>>> cfg = configparser.ConfigParser()
>>> cfg.read_string('[foo]\nx = 1\n...\n')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.11/configparser.py", line 738, in read_string
self.read_file(sfile, source)
File "/usr/lib/python3.11/configparser.py", line 733, in read_file
self._read(f, source)
File "/usr/lib/python3.11/configparser.py", line 1131, in _read
raise e
configparser.ParsingError: Source contains parsing errors: '<string>'
[line 3]: '...\n'
>>> cfg['foo']['x']
'1'
I expect reading to be an all-or-nothing operation -- if the file contains a syntax error it shouldn't modify the ConfigParser object with half of the file's contents
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 558
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python/cpython 的其他 Issue
-
docs pending
难度 2/5 1-3 小时 新手友好度 78/100
-
stdlib type-feature
难度 2/5 1-3 小时 新手友好度 78/100
-
stdlib type-feature
难度 2/5 1-3 小时 新手友好度 72/100
-
build type-bug
难度 2/5 1-3 小时 新手友好度 76/100
-
stdlib topic-email type-feature
难度 2/5 1-3 小时 新手友好度 70/100
相似的 Issue
-
from:qa priority:P2 reliability tech-debt
难度 2/5 1-3 小时 新手友好度 78/100
spec-kitty/spec-kitty#4874 ·
-
fix: inaccuracy ⚠️
难度 2/5 1-3 小时 新手友好度 72/100
uabrc/uabrc.github.io#1255 · 1 条评论 ·
-
kind:bug needs-triage
难度 2/5 1-3 小时 新手友好度 88/100
-
docs
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 84/100
ethereum-optimism/factory#64 ·