The codecs module mostly but not fully supports non str<->bytes codecs
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- 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