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

Inconsistency between b32decode() documentation, docstring and code #62211

Closed
serhiy-storchaka opened this issue May 19, 2013 · 8 comments
Closed
Assignees
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 18011
Nosy @gvanrossum, @warsaw, @bitdancer, @ethanfurman, @serhiy-storchaka
Files
  • b32decode_exception.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2013-05-28.12:36:41.213>
    created_at = <Date 2013-05-19.08:19:09.621>
    labels = ['type-bug', 'library', 'docs']
    title = 'Inconsistency between b32decode() documentation, docstring and code'
    updated_at = <Date 2014-01-08.23:02:51.711>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2014-01-08.23:02:51.711>
    actor = 'r.david.murray'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2013-05-28.12:36:41.213>
    closer = 'serhiy.storchaka'
    components = ['Documentation', 'Library (Lib)']
    creation = <Date 2013-05-19.08:19:09.621>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['30310']
    hgrepos = []
    issue_num = 18011
    keywords = ['patch']
    message_count = 8.0
    messages = ['189571', '189576', '189901', '190201', '190202', '207708', '207710', '207711']
    nosy_count = 7.0
    nosy_names = ['gvanrossum', 'barry', 'r.david.murray', 'docs@python', 'ethan.furman', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue18011'
    versions = ['Python 3.3', 'Python 3.4']

    @serhiy-storchaka
    Copy link
    Member Author

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

    @serhiy-storchaka serhiy-storchaka added docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels May 19, 2013
    @serhiy-storchaka
    Copy link
    Member Author

    Here is a patch which changes TypeError to binascii.Error in b32decode() and fixes the documentation and tests.

    @serhiy-storchaka
    Copy link
    Member Author

    Are there any objections?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 28, 2013

    New changeset 0b9bcb2ac145 by Serhiy Storchaka in branch '3.3':
    Issue bpo-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 bpo-18011: base64.b32decode() now raises a binascii.Error if there are
    http://hg.python.org/cpython/rev/7446f53ba2d2

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 28, 2013

    New changeset 29a823f31465 by Serhiy Storchaka in branch 'default':
    Issue bpo-18011: Silence an unrelated noise introduced in changeset 1b5ef05d6ced.
    http://hg.python.org/cpython/rev/29a823f31465

    @bitdancer
    Copy link
    Member

    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.

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @bitdancer
    Copy link
    Member

    But code could be catching TypeError specifically looking for the alphabet error, since that is how it was documented.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants