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 摘要。