classification
Title: confusing error message for rot13 codec
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lemburg, miss-islington, serhiy.storchaka, xiang.zhang
Priority: normal Keywords: patch

Created on 2018-02-25 05:22 by xiang.zhang, last changed 2018-03-25 04:33 by xiang.zhang. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5869 merged xiang.zhang, 2018-02-25 05:43
PR 6227 merged miss-islington, 2018-03-25 04:10
Messages (3)
msg312775 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-02-25 05:22
rot13 codec does a str translate operation. But it doesn't check the input type and then the error message would be quite confusing, especially for bytes:

>>> codecs.encode(b'abc', 'rot13')
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/rot_13.py", line 15, in encode
    return (input.translate(rot13_map), len(input))
TypeError: a bytes-like object is required, not 'dict'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: encoding with 'rot13' codec failed (TypeError: a bytes-like object is required, not 'dict')
msg314393 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-03-25 04:09
New changeset e4ce9fa89cb542dced553710b05de85202bc4715 by Xiang Zhang in branch 'master':
bpo-32943: Fix confusing error message for rot13 codec (GH-5869)
https://github.com/python/cpython/commit/e4ce9fa89cb542dced553710b05de85202bc4715
msg314394 - (view) Author: miss-islington (miss-islington) Date: 2018-03-25 04:30
New changeset 291d5f3e7195659f874fe56b0e3ed717b57597ee by Miss Islington (bot) in branch '3.7':
bpo-32943: Fix confusing error message for rot13 codec (GH-5869)
https://github.com/python/cpython/commit/291d5f3e7195659f874fe56b0e3ed717b57597ee
History
Date User Action Args
2018-03-25 04:33:48xiang.zhangsetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
components: + Library (Lib)
versions: - Python 3.6
2018-03-25 04:30:42miss-islingtonsetnosy: + miss-islington
messages: + msg314394
2018-03-25 04:10:37miss-islingtonsetpull_requests: + pull_request5966
2018-03-25 04:09:27xiang.zhangsetmessages: + msg314393
2018-02-25 05:45:22xiang.zhangsetnosy: + lemburg
2018-02-25 05:43:20xiang.zhangsetkeywords: + patch
stage: patch review
pull_requests: + pull_request5643
2018-02-25 05:22:05xiang.zhangcreate