ValueError: illegal newline value on 0x85 (NEL)
还没有人认领这个 Issue。
评估
调研方向
从报告中的 open(..., newline=...) reproducer 开始,并针对列出的换行字符将其与 str.splitlines() 进行比较。跟踪 CPython 对文本 I/O 的 newline 验证处理,然后确定或添加相关测试。完成标准是预期的 newline 值具有已定义且经过测试的行为,同时不会导致现有 newline 转换发生回归。
由索引模型根据 Issue 内容生成。
描述
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'
- 主要语言
- 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
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 84/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 86/100
-
🐛 Bug 🔔 Pending processing
难度 2/5 1-3 小时 新手友好度 84/100
jumpserver/jumpserver#17584 ·