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

distutils.upload uses the wrong order of exceptions #65975

Closed
PCManticore mannequin opened this issue Jun 16, 2014 · 4 comments
Closed

distutils.upload uses the wrong order of exceptions #65975

PCManticore mannequin opened this issue Jun 16, 2014 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@PCManticore
Copy link
Mannequin

PCManticore mannequin commented Jun 16, 2014

BPO 21776
Nosy @merwok, @PCManticore, @berkerpeksag, @dstufft
Files
  • distutils.patch
  • issue21776_v2.diff
  • 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 = None
    closed_at = <Date 2016-06-02.20:43:12.589>
    created_at = <Date 2014-06-16.09:33:28.987>
    labels = ['type-bug', 'library']
    title = 'distutils.upload uses the wrong order of exceptions'
    updated_at = <Date 2016-06-02.20:43:12.588>
    user = 'https://github.com/PCManticore'

    bugs.python.org fields:

    activity = <Date 2016-06-02.20:43:12.588>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-06-02.20:43:12.589>
    closer = 'berker.peksag'
    components = ['Distutils']
    creation = <Date 2014-06-16.09:33:28.987>
    creator = 'Claudiu.Popa'
    dependencies = []
    files = ['35653', '41669']
    hgrepos = []
    issue_num = 21776
    keywords = ['patch']
    message_count = 4.0
    messages = ['220705', '258676', '266941', '266942']
    nosy_count = 5.0
    nosy_names = ['eric.araujo', 'Claudiu.Popa', 'python-dev', 'berker.peksag', 'dstufft']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21776'
    versions = ['Python 3.5', 'Python 3.6']

    @PCManticore
    Copy link
    Mannequin Author

    PCManticore mannequin commented Jun 16, 2014

    Hi. Currently, distutils.command.upload has this code:

    try:
    result = urlopen(request)
    status = result.getcode()
    reason = result.msg
    except OSError as e:
    self.announce(str(e), log.ERROR)
    return
    except HTTPError as e:
    status = e.code
    reason = e.msg

    This is wrong because HTTPError is a subclass of OSError and OSError branch will be chosen in case HTTPError is raised. The HTTPError branch was added in 4373f0e4eb21, but after a while socket.error became an alias for OSError, as well for HTTPError. This patch also adds a return in order to prevent an UnboundLocalError (found in bpo-10367 as well), but it can be removed if other solutions are preferable.

    @PCManticore PCManticore mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 16, 2014
    @berkerpeksag
    Copy link
    Member

    Lib/distutils/command/upload.py has changed a bit after d86214c98a9c. Here is an updated patch.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 2, 2016

    New changeset 17e7d6c4f082 by Berker Peksag in branch '3.5':
    Issue bpo-21776: distutils.upload now correctly handles HTTPError
    https://hg.python.org/cpython/rev/17e7d6c4f082

    New changeset 421bc6ae9b6f by Berker Peksag in branch 'default':
    Issue bpo-21776: Merge from 3.5
    https://hg.python.org/cpython/rev/421bc6ae9b6f

    @berkerpeksag
    Copy link
    Member

    Thanks for the patch, Claudiu.

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant