[New-bugs-announce] [issue10643] OSX proxy exceptions parse bug in urllib (crash)

wojas report at bugs.python.org
Tue Dec 7 08:02:44 CET 2010


New submission from wojas <python at m.wojas.nl>:

On OSX (tested with 10.6), urllib will fail to parse the proxy exceptions configuration if no netmask is specified.

On my system the following entries have been added to the proxy exception list: '127.0.0.1' and 'localhost'. The traceback in included below.

The problem:
 * In 'm = re.match(r"(\d+(?:\.\d+)*)(/\d+)?", value)' the netmask is optional
 * But 'mask = int(m.group(2)[1:])' implicitly assumes it exists.

This can be fixed by using 32 as a default netmask if none is specified, see attached patch: 'mask = int(m.group(2)[1:]) if m.group(2) else 32'

TRACEBACK:

  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_mechanize.py", line 203, in open
    return self._mech_open(url, data, timeout=timeout)
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_mechanize.py", line 230, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_opener.py", line 188, in open
    req = meth(req)
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_http.py", line 316, in http_request
    self.rfp.read()
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_http.py", line 242, in read
    f = self._opener.open(req)
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_mechanize.py", line 203, in open
    return self._mech_open(url, data, timeout=timeout)
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_mechanize.py", line 230, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_opener.py", line 193, in open
    response = urlopen(self, req, data)
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_urllib2_fork.py", line 344, in _open
    '_open', req)
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_urllib2_fork.py", line 332, in _call_chain
    result = func(*args)
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_urllib2_fork.py", line 666, in <lambda>
    meth(r, proxy, type))
  File "/Users/wojas/dev/ds/lib/python2.6/site-packages/mechanize/_urllib2_fork.py", line 678, in proxy_open
    if req.get_host() and self._proxy_bypass(req.get_host()):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib.py", line 1407, in proxy_bypass
    return proxy_bypass_macosx_sysconf(host)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib.py", line 1379, in proxy_bypass_macosx_sysconf
    mask = int(m.group(2)[1:])
TypeError: 'NoneType' object is unsubscriptable

----------
components: Extension Modules
files: urllib-osx-proxy-patch.diff
keywords: patch
messages: 123524
nosy: wojas
priority: normal
severity: normal
status: open
title: OSX proxy exceptions parse bug in urllib (crash)
versions: Python 2.6
Added file: http://bugs.python.org/file19967/urllib-osx-proxy-patch.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10643>
_______________________________________


More information about the New-bugs-announce mailing list