Issue #21776: distutils.upload now correctly handles HTTPError

Initial patch by Claudiu Popa.
This commit is contained in:
Berker Peksag 2016-06-02 13:45:53 -07:00
parent 947ff38725
commit 6a8e626a60
3 changed files with 40 additions and 8 deletions

View file

@ -181,21 +181,21 @@ class upload(PyPIRCCommand):
result = urlopen(request)
status = result.getcode()
reason = result.msg
except OSError as e:
self.announce(str(e), log.ERROR)
raise
except HTTPError as e:
status = e.code
reason = e.msg
except OSError as e:
self.announce(str(e), log.ERROR)
raise
if status == 200:
self.announce('Server response (%s): %s' % (status, reason),
log.INFO)
if self.show_response:
text = self._read_pypi_response(result)
msg = '\n'.join(('-' * 75, text, '-' * 75))
self.announce(msg, log.INFO)
else:
msg = 'Upload failed (%s): %s' % (status, reason)
self.announce(msg, log.ERROR)
raise DistutilsError(msg)
if self.show_response:
text = self._read_pypi_response(result)
msg = '\n'.join(('-' * 75, text, '-' * 75))
self.announce(msg, log.INFO)