kennethreitz/requests — Issue #471: Raise ValueError, not KeyError, in case the schema is unknown
Author: wbolster
Created: 2012-03-07 00:06:10+00:00
State: open

Requests raises ValueError for most incorrect urls, but in case the schema is unknown (e.g. "foo://a/b/c"), KeyError is used.

>>> requests.get('foo://a/b/c')
KeyError: u'foo'

>>> requests.get('x//a/b/c')
ValueError: Invalid URL 'x//a/b/c': No schema supplied

This makes it hard to differentiate between "erroneous url" versus "http request failed".