Skip to content

Fix exception causes in package_index.py #2189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions setuptools/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
def parse_requirement_arg(spec):
try:
return Requirement.parse(spec)
except ValueError:
except ValueError as e:
raise DistutilsError(
"Not a URL, existing file, or requirement spec: %r" % (spec,)
)
) from e


def parse_bdist_wininst(name):
Expand Down Expand Up @@ -772,15 +772,15 @@ def open_url(self, url, warning=None):
if warning:
self.warn(warning, msg)
else:
raise DistutilsError('%s %s' % (url, msg))
raise DistutilsError('%s %s' % (url, msg)) from v
except urllib.error.HTTPError as v:
return v
except urllib.error.URLError as v:
if warning:
self.warn(warning, v.reason)
else:
raise DistutilsError("Download error for %s: %s"
% (url, v.reason))
% (url, v.reason)) from v
except http_client.BadStatusLine as v:
if warning:
self.warn(warning, v.line)
Expand All @@ -789,13 +789,13 @@ def open_url(self, url, warning=None):
'%s returned a bad status line. The server might be '
'down, %s' %
(url, v.line)
)
) from v
except (http_client.HTTPException, socket.error) as v:
if warning:
self.warn(warning, v)
else:
raise DistutilsError("Download error for %s: %s"
% (url, v))
% (url, v)) from v

def _download_url(self, scheme, url, tmpdir):
# Determine download filename
Expand Down