PoolManager.request() with invalid scheme produces KeyError
See original GitHub issue>>> pm = urllib3.PoolManager
>>> pm.request('GET', 'FAKESCHEME://github.com')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/site-packages/urllib3/request.py", line 69, in request
**urlopen_kw)
File "/usr/local/lib/python3.5/site-packages/urllib3/request.py", line 90, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/usr/local/lib/python3.5/site-packages/urllib3/poolmanager.py", line 155, in urlopen
conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
File "/usr/local/lib/python3.5/site-packages/urllib3/poolmanager.py", line 128, in connection_from_host
pool = self._new_pool(scheme, host, port)
File "/usr/local/lib/python3.5/site-packages/urllib3/poolmanager.py", line 87, in _new_pool
pool_cls = self.pool_classes_by_scheme[scheme]
KeyError: 'FAKESCHEME'
We should be fetching by that scheme more resiliently, and raising a more specific error message - possibly a LocationValueError?
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
Issue24667 - Issue Tracker - Python.org
Looking further into this issue, OrderedDict.pop() using the key returned from the KeyError (using eval(str(error))) also yields a KeyError.
Read more >python - LIME feature explaining produces invalid key error
I needed to first convert everything to a numpy array: class_names = X_train.columns X_train = X_train.to_numpy() X_test = X_test.to_numpy() ...
Read more >T106212 KeyError in urllib3 since Python 3.5.0b3
It seems that recently the Python 3.6 builds fail due to urllib3 raising a KeyError (see https://travis-ci.org/xZise/pywikibot-core/builds/71550286#L7189):.
Read more >Python Module Index - Requests Documentation
When you make a request, Requests makes educated guesses about the ... or if the response contains invalid JSON, attempting r.json() raises ...
Read more >mozilla-central: changeset 607536 ...
PoolManager() + >>> r = http.request('GET', ... + +* Fix issue where URLs containing invalid characters within ``Url.auth`` would + raise an ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’d be inclined to say that we should approach this with a YAGNI train of thought. I agree with @shazow that a custom exception makes sense, but it really only makes sense if we allow pluggable schemes. If we don’t ever do that, then I don’t think that a custom exception is warranted.
Probably. Will reopen if necessary.