Codec error handling callback should return newpos > start

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

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

評価

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

調査の方向性

まず PEP 293 を読み、issue に記載されている encoder/decoder error-callback の動作を追跡します。返された newpos の値が start と等しいか、start より小さい場合にどのように扱われるかを調査し、その後、報告されたループと無効な位置のケースをカバレッジに追加します。これらの callbacks が処理を進行させない状態や無制限のバッファリングを引き起こさなくなれば完了です。

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

説明

topic-unicode type-feature

According to PEP 293, the codec error handling callback should either raise an exception or return a pair (replacement, newpos). newpos specifies a new position within object, where the encoder/decoder will continue encoding/decoding. Negative values for newpos are treated as being relative to end of object. PEP 293 does not specify the bound of newpos, and this is a problem.

If newpos == start, the codec will not advance. If replacement is empty, it will just hang in an infinite loop, calling the callback again and again. If replacement is not empty, it will additionally add it in an internal buffer, and finally, after long time, you will get a MemoryError. If newpos < start, the behavior may be even more weird.

Before fixing other errors in #81000 it even caused a crash, but now it is only an infinite loop.

I propose to limit the returning value by range [start+1, len(object)].

@malemburg, @doerwalter, @vstinner

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

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

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

はじめの一歩

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

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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