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.

Author Windson Yang
Recipients Windson Yang
Date 2019-03-28.00:11:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1553731868.7.0.689003457524.issue36453@roundup.psfhosted.org>
In-reply-to
Content
Is it an expected behavior the get_importer function only returns the first valid path_hook(importer) from sys.path_hooks?

def get_importer(path_item):
    """Retrieve a finder for the given path item

    The returned finder is cached in sys.path_importer_cache
    if it was newly created by a path hook.

    The cache (or part of it) can be cleared manually if a
    rescan of sys.path_hooks is necessary.
    """
    try:
        importer = sys.path_importer_cache[path_item]
    except KeyError:
        for path_hook in sys.path_hooks:
            try:
                importer = path_hook(path_item)
                sys.path_importer_cache.setdefault(path_item, importer)
                break
            except ImportError:
                pass
        else:
            importer = None
    return importer

Does the order in sys.path_hooks matters? We should document it if it does. Btw get_importer function is lack of test.
History
Date User Action Args
2019-03-28 00:11:08Windson Yangsetrecipients: + Windson Yang
2019-03-28 00:11:08Windson Yangsetmessageid: <1553731868.7.0.689003457524.issue36453@roundup.psfhosted.org>
2019-03-28 00:11:08Windson Yanglinkissue36453 messages
2019-03-28 00:11:08Windson Yangcreate