Skip to content
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

Merged
merged 3 commits into from
Mar 25, 2018

Conversation

zhangyangyu
Copy link
Member

@zhangyangyu zhangyangyu commented Feb 25, 2018

### Codec APIs

class Codec(codecs.Codec):
def encode(self, input, errors='strict'):
_check_str(input)
return (input.translate(rot13_map), len(input))
Copy link
Member

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)?

Copy link
Member Author

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.

@serhiy-storchaka
Copy link
Member

I think it can be backported to 3.7. @ned-deily

@zhangyangyu zhangyangyu merged commit e4ce9fa into python:master Mar 25, 2018
@miss-islington
Copy link
Contributor

Thanks @zhangyangyu for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-6227 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 25, 2018
(cherry picked from commit e4ce9fa)

Co-authored-by: Xiang Zhang <angwerzx@126.com>
miss-islington added a commit that referenced this pull request Mar 25, 2018
(cherry picked from commit e4ce9fa)

Co-authored-by: Xiang Zhang <angwerzx@126.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants