-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-136278: Document codecs.escape_encode() and codecs.escape_decode() #136314
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
base: main
Are you sure you want to change the base?
Conversation
Hi @StanFromIreland, Thanks for the feedback and guidance throughout this process! Looking forward to your review! Best regards, |
Hello, in the future please reuse prs, it creates clutter otherwise. I will review later. |
Thanks, noted! I'll make sure to reuse PRs going forward. |
Doc/library/codecs.rst
Outdated
| zlib_codec | zip, zlib | Compress the operand using | :meth:`zlib.compress` / | | ||
| | | gzip. | :meth:`zlib.decompress` | | ||
+----------------------+------------------+------------------------------+------------------------------+ | ||
|
||
.. function:: codecs.escape_encode(input, errors='strict') |
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.
Where is errors='strict'
from?
cpython/Modules/_codecsmodule.c
Line 178 in 5de7e3f
errors: str(accept={str, NoneType}) = None |
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.
Thanks for catching that!
I've updated the function signature to use errors=None in accordance with the actual default in _codecsmodule.c.
Let me know if there's anything else you'd like me to adjust. Appreciate your time and feedback!
This PR adds documentation for the functions codecs.escape_encode() and codecs.escape_decode(), which provide a way to encode and decode byte sequences using escape sequences, similar to how repr(bytes) works.
These APIs are primarily used by the pickle module for handling escaped byte sequences safely.
The documentation includes function signatures, a usage example, and background information referencing the previous usage in Python 2's string_escape codec and considerations for reviving this as bytes_escape.
Closes: #136278
📚 Documentation preview 📚: https://cpython-previews--136314.org.readthedocs.build/