classification
Title: distutils.upload uses the wrong order of exceptions
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Claudiu.Popa, berker.peksag, dstufft, eric.araujo, python-dev
Priority: normal Keywords: patch

Created on 2014-06-16 09:33 by Claudiu.Popa, last changed 2016-06-02 20:43 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
distutils.patch Claudiu.Popa, 2014-06-16 09:33 review
issue21776_v2.diff berker.peksag, 2016-01-20 12:39 review
Messages (4)
msg220705 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-06-16 09:33
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 issue10367 as well), but it can be removed if other solutions are preferable.
msg258676 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-01-20 12:39
Lib/distutils/command/upload.py has changed a bit after d86214c98a9c. Here is an updated patch.
msg266941 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-02 20:37
New changeset 17e7d6c4f082 by Berker Peksag in branch '3.5':
Issue #21776: distutils.upload now correctly handles HTTPError
https://hg.python.org/cpython/rev/17e7d6c4f082

New changeset 421bc6ae9b6f by Berker Peksag in branch 'default':
Issue #21776: Merge from 3.5
https://hg.python.org/cpython/rev/421bc6ae9b6f
msg266942 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-06-02 20:43
Thanks for the patch, Claudiu.
History
Date User Action Args
2016-06-02 20:43:12berker.peksagsetstatus: open -> closed
resolution: fixed
messages: + msg266942

stage: patch review -> resolved
2016-06-02 20:37:11python-devsetnosy: + python-dev
messages: + msg266941
2016-01-20 12:39:22berker.peksagsetfiles: + issue21776_v2.diff
versions: + Python 3.6
nosy: + berker.peksag

messages: + msg258676

stage: patch review
2014-06-16 09:33:29Claudiu.Popacreate