python / python/cpython

Revive binascii.Incomplete?

未關閉
#148,108 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

3.15 extension-modules type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Feature or enhancement

binascii.Incomplete was only used in BinHex 4 (HQX) decoder. After removing that decoder in #89248, binascii.Incomplete became orphaned. It could be removed too.

We can reuse it for decoding errors that can potentially be fixed by reading more data. Not all incomplete data errors can be detected, in some codecs incomplete data can be valid.

For compatibility, binascii.Incomplete should be made a subclass of binascii.Error.

We perhaps will need to add also the final parameter (True by default). If it is false, then binascii.Incomplete will be raised if the last group of data is ambiguous, if the result of decoding concatenated data can be different from concatenation of independently decoded chunks.

I am not sure that this feature will be very useful, but without it we cannot reliably decode chunked data if it was split not on boundaries between groups. Although having only this feature the incremental decoder will be vulnerable to quadratic complexity issue. For example, reading line by line and decoding Base64 data split on 76 column lines except the first line containing 75 alphabetic characters will have quadratic complexity.

Linked PRs
  • gh-148109

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

此 issue 聚焦於 binascii.Incomplete、已移除的 BinHex/HQX 解碼器,以及分塊 Base64 解碼。請先檢視 binascii 解碼器的進入點與相關工作 gh-148109;釐清該例外應移除還是重複使用、其 Error 子類別關係,以及最終語意。完成條件是確認一致的範圍,並為不完整輸入與串接輸入加入測試。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
backend
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。