python / python/cpython

ValueError: illegal newline value on 0x85 (NEL)

オープン
#97,544 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

interpreter-core type-feature
主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

説明

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'

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

報告された open(..., newline=...) の reproducer から始め、列挙された改行文字について str.splitlines() と比較します。newline の検証に関する CPython のテキスト I/O 処理を追跡し、その後、関連するテストを特定するか追加します。意図された newline の値に、既存の newline 変換を後退させることなく、定義済みでテストされた動作があれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。