[Python-modules-team] Bug#870701: python-pip-whl: Incompatible versions of requests and urllib3 cause TypeError when index is unavailable

Stefano Mazzucco nospam at curso.re
Fri Aug 4 10:41:28 UTC 2017


Package: python-pip-whl
Version: 9.0.1-2
Severity: normal

Dear Maintainer,

when trying to install a package with pip and the PyPI index server is unavailable,
urllib3 raises an error.

I ran into this issue when using an extra-index-url option pointing to a server
that was down.

For example:

$ pip install pyyml
Collecting pyyml
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 342, in run
    requirement_set.prepare_files(finder)
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 792, in get_page
    "Cache-Control": "max-age=600",
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 386, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment
    total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'


The expected behavior would be that pip logs a warning and fails gracefully, e.g.

$ pip install pyyml
Collecting pyyml
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f9d9c4937f0>: Failed to establish a new connection: [Errno 111] Connection refused',)': /simple/pyyml/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f9d9c4932b0>: Failed to establish a new connection: [Errno 111] Connection refused',)': /simple/pyyml/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f9d9c493320>: Failed to establish a new connection: [Errno 111] Connection refused',)': /simple/pyyml/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f9d9c493400>: Failed to establish a new connection: [Errno 111] Connection refused',)': /simple/pyyml/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f9d9c493b00>: Failed to establish a new connection: [Errno 111] Connection refused',)': /simple/pyyml/
  Could not find a version that satisfies the requirement pyyml (from versions: )
No matching distribution found for pyyml

Upstream references can be found e.g. at
https://github.com/shazow/urllib3/issues/567

As a workaround, using a more recent version of the "requests" wheel file in /usr/share/python-wheels
fixes the problem. Additionally, one should also replace the "urllib3" and "chardet" wheels so that
"requests" does not show warnings:

- requests: 2.18
- urllib3: 1.22
- chardet: 3.0.4

Thanks


-- System Information:
Debian Release: 9.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages python-pip-whl depends on:
ii  ca-certificates  20161130+nmu1

python-pip-whl recommends no packages.

python-pip-whl suggests no packages.

-- no debconf information



More information about the Python-modules-team mailing list