The codecs module mostly but not fully supports non str<->bytes codecs
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
There's in the codecs module an option for charbuffertype which allows bytes<->bytes codecs, but if there were a type for the encoded value, it would allow cleaner implementation of str<->str codecs, or more...
Most codecs in CPython use decoded str and encoded bytes, there are also codecs that have decoded bytes and encoded bytes, like base64 (note that a base64 codec arguably could be one that considers decoded bytes and encoded str).
I had been more or less perverting the codecs module to implement things like COBS (fundamentally bytes<->bytes), bubblebabble (I did bytes<->bytes but it should encode to str), and recently ANSI escape filtering, as a str<->str codec that works by implementing a virtual terminal, with a screen buffer. To make it work I only had to do self.bytebuffer = "" in the StreamReader constructor, but since there's a charbuffertype, maybe we could use a bytesbuffertype, and open the flood gates to all kinds of creative abuse.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 codecs 模块开始,检查 StreamReader 构造函数,包括现有的 charbuffertype 行为。确定编码值类型和解码值类型的预期模型,然后定义超出 str/bytes 的更广泛 codec 支持应涵盖哪些内容;只有在该范围及其预期行为确定并实现后,工作才算完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100