in windows XP, python 2.5 and 2.6 I tested the following code:
import urllib2
proxy= urllib2.ProxyHandler({'http': '127.0.0.1:8080'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
urllib2.urlopen('http://www.google.com/')
I have a proxy running at 127.0.0.1:8080 which works (I can use it in proxyswitchy and can see sites being blocked when it's not turned on).
In the above code I get a BadStatusLine exception from line 349 of httplib.py.
if I change it to a socks proxy,
proxy= urllib2.ProxyHandler({'socks': '127.0.0.1:8080'})
then it does not get used at all - in that case, the proxy is not used at all.
I got the code from the question at http://stackoverflow.com/questions/1450132/proxy-with-urllib2 and it's almost exactly the same - what could be going wrong?