gh-82663: Clarify codecs.iterdecode/encode docs#136497
Conversation
malemburg
left a comment
There was a problem hiding this comment.
I'm not sure whether we should do this. The codecs machinery is not tied to str<->bytes only.
While it's true that the current implementation of those two functions will only work with iterators of certain types, this is an (unwanted) side-effect of their use of "" and b"" in the implementation. More correct would be to use input[:0] to finalize the encoder.
Perhaps it's better to write e.g. "For most encodings, iterator must yield :class:str objects."
|
Ok, I had another look at what Walter had implemented for the incremental encoders/decoders and he does indeed assume that only str<->bytes encoding can be used. |
|
Thanks, @StanFromIreland |
|
Thanks @StanFromIreland for the PR, and @malemburg for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Thanks @StanFromIreland for the PR, and @malemburg for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
) Closes pythonGH-82663 (cherry picked from commit 4b41b20) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
) Closes pythonGH-82663 (cherry picked from commit 4b41b20) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
|
GH-136512 is a backport of this pull request to the 3.13 branch. |
|
GH-136513 is a backport of this pull request to the 3.14 branch. |
…nGH-136497) (python#136513) pythongh-82663: Clarify `codecs.iterdecode/encode` docs (pythonGH-136497) Closes pythonGH-82663 (cherry picked from commit 4b41b20) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
I do not think there is a need for an example as @doerwalter suggested, but I do not mind adding one.
codecs.BufferedIncrementalDecoderdocumentation #82663📚 Documentation preview 📚: https://cpython-previews--136497.org.readthedocs.build/