Issue 32943: confusing error message for rot13 codec - Python tracker

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
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 2022-04-11 14:58 by admin. 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