The codecs module mostly but not fully supports non str<->bytes codecs
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem Modul codecs und untersuche den Konstruktor von StreamReader, einschließlich des bestehenden Verhaltens von charbuffertype. Ermittle das beabsichtigte Modell für codierte und decodierte Werttypen und lege anschließend fest, was eine umfassendere Codec-Unterstützung über str/bytes hinaus abdecken sollte; die Arbeit ist erst abgeschlossen, wenn dieser Umfang und das erwartete Verhalten festgelegt und implementiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100