[New-bugs-announce] [issue2670] urllib2 build_opener() fails if two handlers use the same default base class

Tom Lynn report at bugs.python.org
Tue Apr 22 22:17:56 CEST 2008


New submission from Tom Lynn <tlynn at users.sourceforge.net>:

urllib2.py:424 (Py 2.4) or urllib2.py:443 (Py 2.5) in build_opener()::

        skip = []
        for klass in default_classes:
            for check in handlers:
                if inspect.isclass(check):
                    if issubclass(check, klass):
                        skip.append(klass)
                elif isinstance(check, klass):
                    skip.append(klass)
        for klass in skip:
           default_classes.remove(klass)

This can cause klass to be appended to skip multiple times,
which then causes an exception in the final line quoted above.

skip should be a set (and append changed to add), or "if klass
not in skip:" should be added before each "skip.append(klass)".

----------
components: Library (Lib)
messages: 65683
nosy: tlynn
severity: normal
status: open
title: urllib2 build_opener() fails if two handlers use the same default base class
type: behavior
versions: Python 2.4, Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2670>
__________________________________


More information about the New-bugs-announce mailing list