dsandler.org

getproxies() in python2.3/mac

June 7th, 2007

Irritating:

$ python2.3 -c 'import urllib; print urllib.getproxies()'
{}
$ python2.4 -c 'import urllib; print urllib.getproxies()'
{'http': 'http://localhost:8501'}

Is it documented somewhere that getproxies() just plain doesn’t work in OS X with the Apple-supplied 2.3 build?

3 responses

  1. Jon  

    This is because in python2.3′s urllib.py, Mac OS is detected by os.name == ‘mac’, but os.name actually returns ‘posix’ with the apple-supplied build. In python2.5, Mac OS detection now uses sys.platform == ‘darwin’.

    But, I’ve never seen that documented. Of course, I’ve never seen the function getproxies() itself documented, either.

    comment posted at 12:33 pm on 07 Jun 2007

  2. ctate  

    A fellow tells me this is because Python 2.3 urllib had a bug in getproxies(), since fixed.

    comment posted at 12:38 pm on 07 Jun 2007

  3. dsandler  

    @ctate: Yeah, looking through the source it appears 2.3 has an OS9-centric test for Macness:

    [python2.3/urllib.py:1251] if os.name == 'mac':
    

    2.4 chooses instead the more accurate incantation for OS X:

    [python2.4/urllib.py:1190] if sys.platform == 'darwin':
    

    Sigh.

    @Jon: getproxies() isn’t documented, which is fine by me, but because urlopen() relies on it to Do The Right Thing, its correctness is critical.

    comment posted at 1:26 pm on 07 Jun 2007

Add a comment

html help (show)

newer: older: