◐ Shell
clean mode source ↗

Issue 6894: urllib2 doesn't respect "no_proxy" environment (python2.6.2)

I discovered recently that urllib2 doesn't respect the "no_proxy" 
environment variable on linux (and on other platforms too, I think).

Here is an example of the problem :
- Set http_proxy and no_proxy environment variables (for instance 
no_proxy="localhost")

proxy_handler = urllib2.ProxyHandler()
opener = urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)

and then open an "outside" url : everything is OK (urllib2 reads 
correctly http_proxy), but for "localhost", it tries to open it 
through the proxy.

You would expect urllib2 to understand no_proxy, all the more since 
all the needed code is already available in urllib.

I have prepared a patch for urllib2 which does correct that bug.

I don't have other versions of python installed, so I couldn't check 
that se bug is still present there.