ValueError: illegal newline value on 0x85 (NEL)
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
In attempting to harmonize the path pie implementation with more modern constructs, I'm seeking also to utilize the newline argument to open instead of explicitly substituting characters.
When I do, however, I find that some tests start to fail when NEL is passed as a newline character:
$ py -c "open('foo', 'w', newline='\x85')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: illegal newline value:
At least in some contexts, Python recognizes NEL as a line separator:
>>> 'a\x85b\x1ec'.splitlines()
['a', 'b', 'c']
See also #66428 for some background.
According to the wikipedia article, a conforming application should honor a number of characters as newlines:
>>> newlines = '\x0a', '\x0b', '\x0c', '\x0d', '\x0d\x0a', '\u0085', '\u2028', '\u2029'
>>> for candidate in newlines:
... try: x=open('foo', 'w', newline=candidate)
... except ValueError: print('failed on', repr(candidate))
...
failed on '\x0b'
failed on '\x0c'
failed on '\x85'
failed on '\u2028'
failed on '\u2029'
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从报告中的 open(..., newline=...) reproducer 开始,并针对列出的换行字符将其与 str.splitlines() 进行比较。跟踪 CPython 对文本 I/O 的 newline 验证处理,然后确定或添加相关测试。完成标准是预期的 newline 值具有已定义且经过测试的行为,同时不会导致现有 newline 转换发生回归。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100