Python on OSX proxy bug with curl

I received a lovely stack trace trying to run a python script that makes an external call using curl. The meat of it:

File “/Library/Python/2.6/site-packages/pyechonest/util.py”, line 52, in call
f = urllib.urlopen(url)
File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib.py”, line 87, in urlopen
File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib.py”, line 203, in open
File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib.py”, line 310, in open_http
File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib.py”, line 1555, in proxy_bypass
File “/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib.py”, line 1425, in proxy_bypass_macosx_sysconf

This is a bug due to how python on OSX parses the values in the proxy bypass box in the system’s Proxy configuration. If you have an explicit IP, it will bomb out. Remove the explicitly specified IP or change it to a name value to get around this bug. Netblocks (such as “10/8”) won’t cause it to bomb — just a definite IP like 1.2.3.4.

One Comments

  • Andrew

    January 2, 2014

    Awesome – Thanks for helping me solve this confusing bug!

Leave a Reply