Issue #21722: The distutils "upload" command now exits with a non-zero return code when uploading fails.
Patch by Martin Dengler.
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index c43607f..9aa54ee 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -10,7 +10,7 @@
import cStringIO as StringIO
from hashlib import md5
-from distutils.errors import DistutilsOptionError
+from distutils.errors import DistutilsError, DistutilsOptionError
from distutils.core import PyPIRCCommand
from distutils.spawn import spawn
from distutils import log
@@ -181,7 +181,7 @@
self.announce(msg, log.INFO)
except socket.error, e:
self.announce(str(e), log.ERROR)
- return
+ raise
except HTTPError, e:
status = e.code
reason = e.msg
@@ -190,5 +190,6 @@
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)