diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-06-19 03:07:46 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-06-19 03:07:46 (GMT) |
commit | 2e4d3b133a8fe7be5469bc8f0d1a0f80a57f608c (patch) | |
tree | e559882cf65c6410f6997902933856c81b4c339d /Lib/distutils/command/upload.py | |
parent | 845fd9aa445f0a4a441fbe0bc3c1e1e318d1f217 (diff) | |
download | cpython-2e4d3b133a8fe7be5469bc8f0d1a0f80a57f608c.zip cpython-2e4d3b133a8fe7be5469bc8f0d1a0f80a57f608c.tar.gz cpython-2e4d3b133a8fe7be5469bc8f0d1a0f80a57f608c.tar.bz2 |
Issue #21722: The distutils "upload" command now exits with a non-zero return code when uploading fails.
Patch by Martin Dengler.
Diffstat (limited to 'Lib/distutils/command/upload.py')
-rw-r--r-- | Lib/distutils/command/upload.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py index d6762e4..180be7c 100644 --- a/Lib/distutils/command/upload.py +++ b/Lib/distutils/command/upload.py @@ -2,10 +2,6 @@ Implements the Distutils 'upload' subcommand (upload package to PyPI).""" -from distutils.errors import * -from distutils.core import PyPIRCCommand -from distutils.spawn import spawn -from distutils import log import sys import os, io import socket @@ -13,6 +9,10 @@ import platform from base64 import standard_b64encode from urllib.request import urlopen, Request, HTTPError from urllib.parse import urlparse +from distutils.errors import DistutilsError, DistutilsOptionError +from distutils.core import PyPIRCCommand +from distutils.spawn import spawn +from distutils import log # this keeps compatibility for 2.3 and 2.4 if sys.version < "2.5": @@ -184,7 +184,7 @@ class upload(PyPIRCCommand): reason = result.msg except OSError as e: self.announce(str(e), log.ERROR) - return + raise except HTTPError as e: status = e.code reason = e.msg @@ -193,8 +193,9 @@ class upload(PyPIRCCommand): self.announce('Server response (%s): %s' % (status, reason), log.INFO) else: - self.announce('Upload failed (%s): %s' % (status, reason), - log.ERROR) + 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)) |