-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-32943: Fix confusing error message for rot13 codec #5869
Conversation
Lib/encodings/rot_13.py
Outdated
### Codec APIs | ||
|
||
class Codec(codecs.Codec): | ||
def encode(self, input, errors='strict'): | ||
_check_str(input) | ||
return (input.translate(rot13_map), len(input)) |
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.
What if just use str.translate(input, rot13_map)
?
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 love this approach. It avoids making the code ugly.
This reverts commit 728f772.
I think it can be backported to 3.7. @ned-deily |
Thanks @zhangyangyu for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
GH-6227 is a backport of this pull request to the 3.7 branch. |
(cherry picked from commit e4ce9fa) Co-authored-by: Xiang Zhang <angwerzx@126.com>
https://bugs.python.org/issue32943