This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: urllib2 build_opener() fails if two handlers use the same default base class
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.4, Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, tlynn
Priority: normal Keywords:

Created on 2008-04-22 20:17 by tlynn, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg65683 - (view) Author: Tom Lynn (tlynn) Date: 2008-04-22 20:17
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)".
msg65684 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-04-22 21:18
Corrected as r62463 (trunk) and r62464 (2.5 branch).

Thanks for the report!
History
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46922
2008-04-22 21:18:47amaury.forgeotdarcsetstatus: open -> closed
resolution: fixed
messages: + msg65684
nosy: + amaury.forgeotdarc
2008-04-22 20:17:55tlynncreate