1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
Description: Properly catch requests' HTTPError in index.py
This resolves issue #4195.
.
In index.py's index retrieval routine we were catching
requests.HTTPError to log and ignore 404s and other similar HTTP server
errors when pulling from (extra-)index-urls. Unfortunately, the actual
path to that exception is requests.exceptions.HTTPError and the alias we
were using does not work when pip is installed with unvendored libs as
with the debian packaged pip.
.
Thankfully the fix is simple. Import and use
requests.exceptions.HTTPError. This comes with the added bonus of
fitting in with the existing handling for RetryError and SSLError. With
this change in place upstream pip and downstream packaged pip should
both catch this exception properly.
.
Note: I've not added any tests cases as I'm unsure how to test the
distro packaging case within pip's testsuite. However, the existing test
suite should hopefully cover that this isn't a regression and I've
manually confirmed that this works with a hacked up debian package
install. Also this is how we handle RetryError and SSLError.
Author: Clark Boylan <clark.boylan@gmail.com>
Date: Fri, 29 Mar 2019 10:17:31 -0700
Origin: upstream, https://github.com/pypa/pip/pull/6367/commits/f8292a304deebcf0e4cda2e40caa226c70030f11
Bug-Debian: https://bugs.debian.org/837764
Last-Update: 2019-03-30
--- python-pip-9.0.1.orig/pip/index.py
+++ python-pip-9.0.1/pip/index.py
@@ -34,7 +34,7 @@ from pip._vendor import html5lib, reques
from pip._vendor.packaging.version import parse as parse_version
from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.packaging import specifiers
-from pip._vendor.requests.exceptions import SSLError
+from pip._vendor.requests.exceptions import HTTPError, SSLError
from pip._vendor.distlib.compat import unescape
@@ -809,7 +809,7 @@ class HTMLPage(object):
return
inst = cls(resp.content, resp.url, resp.headers)
- except requests.HTTPError as exc:
+ except HTTPError as exc:
cls._handle_fail(link, exc, url)
except SSLError as exc:
reason = ("There was a problem confirming the ssl certificate: "
|