Skip to content

Commit 55bfb7d

Browse files
authored
Merge pull request #2189 from cool-RR/2020-06-11-raise-from
Fix exception causes in package_index.py
2 parents 3955acb + 6588760 commit 55bfb7d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

setuptools/package_index.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
def parse_requirement_arg(spec):
5454
try:
5555
return Requirement.parse(spec)
56-
except ValueError:
56+
except ValueError as e:
5757
raise DistutilsError(
5858
"Not a URL, existing file, or requirement spec: %r" % (spec,)
59-
)
59+
) from e
6060

6161

6262
def parse_bdist_wininst(name):
@@ -772,15 +772,15 @@ def open_url(self, url, warning=None):
772772
if warning:
773773
self.warn(warning, msg)
774774
else:
775-
raise DistutilsError('%s %s' % (url, msg))
775+
raise DistutilsError('%s %s' % (url, msg)) from v
776776
except urllib.error.HTTPError as v:
777777
return v
778778
except urllib.error.URLError as v:
779779
if warning:
780780
self.warn(warning, v.reason)
781781
else:
782782
raise DistutilsError("Download error for %s: %s"
783-
% (url, v.reason))
783+
% (url, v.reason)) from v
784784
except http_client.BadStatusLine as v:
785785
if warning:
786786
self.warn(warning, v.line)
@@ -789,13 +789,13 @@ def open_url(self, url, warning=None):
789789
'%s returned a bad status line. The server might be '
790790
'down, %s' %
791791
(url, v.line)
792-
)
792+
) from v
793793
except (http_client.HTTPException, socket.error) as v:
794794
if warning:
795795
self.warn(warning, v)
796796
else:
797797
raise DistutilsError("Download error for %s: %s"
798-
% (url, v))
798+
% (url, v)) from v
799799

800800
def _download_url(self, scheme, url, tmpdir):
801801
# Determine download filename

0 commit comments

Comments
 (0)