pypa/pip — pull request #850 by mzipay (2013-03-18 14:29:23+00:00)
Title: HTMLPage.get_page doesn't handle gzip Content-Types

When a response is missing a Content-Encoding header, and the Content-Type indicates gzip, HTMLPage.get_page fails when decoding the content (since it hasn't been gunzipped). Beyond this, the backwardcompat.u function always assumes UTF-8 encoding, but the HTTP default ISO-8859-1 should be supported.

Trying to install Sphinx (1.1.3) last night I ran into both problems:

Exception in thread Thread-4:
Traceback (most recent call last):
File "-------/lib/python3.3/threading.py", line 639, in _bootstrap_inner
self.run()
File "-------/lib/python3.3/threading.py", line 596, in run
self._target(*self._args, **self._kwargs)
File "-------/lib/python3.3/site-packages/pip-1.2.1-py3.3.egg/pip/index.py", line 245, in _get_queued_page
page = self._get_page(location, req)
File "-------/lib/python3.3/site-packages/pip-1.2.1-py3.3.egg/pip/index.py", line 337, in _get_page
return HTMLPage.get_page(link, req, cache=self.cache)
File "-------/lib/python3.3/site-packages/pip-1.2.1-py3.3.egg/pip/index.py", line 466, in get_page
inst = cls(u(contents), real_url, headers)
File "-------/lib/python3.3/site-packages/pip-1.2.1-py3.3.egg/pip/backwardcompat.py", line 44, in u
return s.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

This commit addresses both issues.