brettcannon/caniusepython3 — pull request #36 by sixohsix (2014-03-13 13:12:54+00:00)
Title: Avoid a crash in distlib when a project cannot be found

We have some private packages that are not on PyPI. When we run "ciu", those packages cause the program to lock up. The crash is caused by an attribute error in `distlib`.

It would be nice to fix the crash upstream, but I don't even know where to begin. It seems to be caused when PyPI sends 300 or 404 HTTP errors. Then something else goes wrong in `distlib`. This patch catches the exception and sets `located` to `None`. Because clearly the package was not located though we may not know why.

Log for the crash:
```
[INFO] Locating soundcloudapi
[ERROR] Failed to get external data for %s: %s
Traceback (most recent call last):
File "/Users/miv/.venvs3.4/caniusepython3_master/lib/python3.4/site-packages/distlib/util.py", line 745, in _get_external_data
resp = urlopen(url)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 153, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 461, in open
response = meth(req, response)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 574, in http_response
'http', request, response, code, msg, hdrs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 499, in error
return self._call_chain(*args)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 433, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 582, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
```