[issue18011] Inconsistency between b32decode() documentation, docstring and code
New submission from Serhiy Storchaka: 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). ---------- assignee: docs@python components: Documentation, Library (Lib) messages: 189571 nosy: barry, docs@python, gvanrossum, serhiy.storchaka priority: normal severity: normal status: open title: Inconsistency between b32decode() documentation, docstring and code type: behavior versions: Python 3.3, Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Serhiy Storchaka added the comment: Here is a patch which changes TypeError to binascii.Error in b32decode() and fixes the documentation and tests. ---------- keywords: +patch stage: -> patch review Added file: http://bugs.python.org/file30310/b32decode_exception.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Serhiy Storchaka added the comment: Here is a patch which changes TypeError to binascii.Error in b32decode() and fixes the documentation and tests. ---------- Added file: http://bugs.python.org/file30311/b32decode_exception.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: ---------- Removed message: http://bugs.python.org/msg189577 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: Removed file: http://bugs.python.org/file30311/b32decode_exception.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Changes by Ethan Furman <ethan@stoneleaf.us>: ---------- nosy: +ethan.furman _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Serhiy Storchaka added the comment: Are there any objections? ---------- assignee: docs@python -> serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Roundup Robot added the comment: 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 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Roundup Robot added the comment: 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 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
R. David Murray added the comment: 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. ---------- nosy: +r.david.murray _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
Serhiy Storchaka added the comment: 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. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
R. David Murray added the comment: But code could be catching TypeError specifically looking for the alphabet error, since that is how it was documented. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18011> _______________________________________
participants (4)
-
Ethan Furman
-
R. David Murray
-
Roundup Robot
-
Serhiy Storchaka