Commit 55bfb7d8 authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #2189 from cool-RR/2020-06-11-raise-from

Fix exception causes in package_index.py
parents 3955acbb 65887607
...@@ -53,10 +53,10 @@ user_agent = _tmpl.format( ...@@ -53,10 +53,10 @@ user_agent = _tmpl.format(
def parse_requirement_arg(spec): def parse_requirement_arg(spec):
try: try:
return Requirement.parse(spec) return Requirement.parse(spec)
except ValueError: except ValueError as e:
raise DistutilsError( raise DistutilsError(
"Not a URL, existing file, or requirement spec: %r" % (spec,) "Not a URL, existing file, or requirement spec: %r" % (spec,)
) ) from e
def parse_bdist_wininst(name): def parse_bdist_wininst(name):
...@@ -772,7 +772,7 @@ class PackageIndex(Environment): ...@@ -772,7 +772,7 @@ class PackageIndex(Environment):
if warning: if warning:
self.warn(warning, msg) self.warn(warning, msg)
else: else:
raise DistutilsError('%s %s' % (url, msg)) raise DistutilsError('%s %s' % (url, msg)) from v
except urllib.error.HTTPError as v: except urllib.error.HTTPError as v:
return v return v
except urllib.error.URLError as v: except urllib.error.URLError as v:
...@@ -780,7 +780,7 @@ class PackageIndex(Environment): ...@@ -780,7 +780,7 @@ class PackageIndex(Environment):
self.warn(warning, v.reason) self.warn(warning, v.reason)
else: else:
raise DistutilsError("Download error for %s: %s" raise DistutilsError("Download error for %s: %s"
% (url, v.reason)) % (url, v.reason)) from v
except http_client.BadStatusLine as v: except http_client.BadStatusLine as v:
if warning: if warning:
self.warn(warning, v.line) self.warn(warning, v.line)
...@@ -789,13 +789,13 @@ class PackageIndex(Environment): ...@@ -789,13 +789,13 @@ class PackageIndex(Environment):
'%s returned a bad status line. The server might be ' '%s returned a bad status line. The server might be '
'down, %s' % 'down, %s' %
(url, v.line) (url, v.line)
) ) from v
except (http_client.HTTPException, socket.error) as v: except (http_client.HTTPException, socket.error) as v:
if warning: if warning:
self.warn(warning, v) self.warn(warning, v)
else: else:
raise DistutilsError("Download error for %s: %s" raise DistutilsError("Download error for %s: %s"
% (url, v)) % (url, v)) from v
def _download_url(self, scheme, url, tmpdir): def _download_url(self, scheme, url, tmpdir):
# Determine download filename # Determine download filename
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment