From: Oleg Broytman Date: Wed, 23 Nov 2016 17:00:53 +0000 (+0300) Subject: Upgrade ez_setup.py X-Git-Tag: 3.1.0~14 X-Git-Url: https://git.phdru.name/?p=m_lib.git;a=commitdiff_plain;h=16010dca6b380048d459e6c1796123f39cc93a8c Upgrade ez_setup.py --- diff --git a/ez_setup.py b/ez_setup.py index 4ef3ee0..950e120 100644 --- a/ez_setup.py +++ b/ez_setup.py @@ -40,6 +40,8 @@ DEFAULT_VERSION = LATEST DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/" DEFAULT_SAVE_DIR = os.curdir +MEANINGFUL_INVALID_ZIP_ERR_MSG = 'Maybe {0} is corrupted, delete it and try again.' + def _python_cmd(*args): """ @@ -104,8 +106,16 @@ def archive_context(filename): old_wd = os.getcwd() try: os.chdir(tmpdir) - with ContextualZipFile(filename) as archive: - archive.extractall() + try: + with ContextualZipFile(filename) as archive: + archive.extractall() + except zipfile.BadZipfile as err: + if not err.args: + err.args = ('', ) + err.args = err.args + ( + MEANINGFUL_INVALID_ZIP_ERR_MSG.format(filename), + ) + raise # going in the directory subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])