-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-82663: Clarify codecs.iterdecode/encode
docs
#136497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
I do not think there is a need for an example as @doerwalter suggested, but I do not mind adding one.
codecs.BufferedIncrementalDecoder
documentation #82663📚 Documentation preview 📚: https://cpython-previews--136497.org.readthedocs.build/