Issue 18011: Inconsistency between b32decode() documentation, docstring and code (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/62211

classification

Title: Inconsistency between b32decode() documentation, docstring and code
Type: behavior Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 3.3, Python 3.4

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: barry, docs@python, ethan.furman, gvanrossum, python-dev, r.david.murray, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-05-19 08:19 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
b32decode_exception.patch serhiy.storchaka,2013-05-19 10:11 review
Messages (8)
msg189571 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-19 08:19
b32decode() documentation says: "A TypeError is raised if s were incorrectly padded or if there are non-alphabet characters present in the string." b32decode() docstring says: "binascii.Error is raised if the input is incorrectly padded or if there are non-alphabet characters present in the input." Actually binascii.Error (which is a ValueError subtype) is raised if the input is incorrectly padded and TypeError is raised if there are non-alphabet characters present in the input. At least 2 of 3 (documentation, docstring and implementation) should be corrected. Base32 support was originally added in 3cc0d8fd4e2b (TypeError was used everywhere) and then modified in eb45f85c4c79 (TypeError was partially changed to binascii.Error).
msg189576 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-19 10:11
Here is a patch which changes TypeError to binascii.Error in b32decode() and fixes the documentation and tests.
msg189901 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-24 07:35
Are there any objections?
msg190201 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-28 12:35
New changeset 0b9bcb2ac145 by Serhiy Storchaka in branch '3.3': Issue #18011: base64.b32decode() now raises a binascii.Error if there are http://hg.python.org/cpython/rev/0b9bcb2ac145 New changeset 7446f53ba2d2 by Serhiy Storchaka in branch 'default': Issue #18011: base64.b32decode() now raises a binascii.Error if there are http://hg.python.org/cpython/rev/7446f53ba2d2
msg190202 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-28 12:43
New changeset 29a823f31465 by Serhiy Storchaka in branch 'default': Issue #18011: Silence an unrelated noise introduced in changeset 1b5ef05d6ced. http://hg.python.org/cpython/rev/29a823f31465
msg207708 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-01-08 22:51
For future reference, because this patch changed the type of an error, it should not have been applied to a maintenance release (3.3). Since the change has already been released in 3.3.3, it is now better not to revert it.
msg207710 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-08 23:00
This is not incompatible change because b32decode() already raised this type of an error. Third-party code which use b32decode() was either incorrect (if it catches only TypeError or binascii.Error when any of them could raised) or is not broken by this change.
msg207711 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-01-08 23:02
But code could be catching TypeError specifically looking for the alphabet error, since that is how it was documented.
History
Date User Action Args
2022-04-11 14:57:45 admin set github: 62211
2014-01-08 23:02:51 r.david.murray set messages: +
2014-01-08 23:00:44 serhiy.storchaka set messages: +
2014-01-08 22:51:47 r.david.murray set nosy: + r.david.murraymessages: +
2013-05-28 12:43:15 python-dev set messages: +
2013-05-28 12:36:41 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2013-05-28 12:35:30 python-dev set nosy: + python-devmessages: +
2013-05-24 07:35:28 serhiy.storchaka set assignee: docs@python -> serhiy.storchakamessages: +
2013-05-20 11:47:51 ethan.furman set nosy: + ethan.furman
2013-05-19 10:16:05 serhiy.storchaka set files: - b32decode_exception.patch
2013-05-19 10:15:54 serhiy.storchaka set messages: -
2013-05-19 10:14:26 serhiy.storchaka set files: + b32decode_exception.patchmessages: +
2013-05-19 10:11:22 serhiy.storchaka set files: + b32decode_exception.patchkeywords: + patchmessages: + stage: patch review
2013-05-19 08:19:09 serhiy.storchaka create