(fullname)
return spec.loader if spec is not None else None
Find a "loader" object for fullname

    This is a backwards compatibility wrapper around
    importlib.util.find_spec that converts most failures to ImportError
    and only returns the loader rather than the full spec
Find a "loader" object for fullname
Find a loader object for fullname
def find_loader(fullname):
    """Find a "loader" object for fullname

    This is a backwards compatibility wrapper around
    importlib.util.find_spec that converts most failures to ImportError
    and only returns the loader rather than the full spec
    """
    if fullname.startswith('.'):
        msg = "Relative module name {!r} not supported".format(fullname)
        raise ImportError(msg)
    try:
        spec = importlib.util.find_spec(fullname)
    except (ImportError, AttributeError, TypeError, ValueError) as ex:
        # This hack fixes an impedance mismatch between pkgutil and
        # importlib, where the latter raises other errors for cases where
        # pkgutil previously raised ImportError
        msg = "Error while finding loader for {!r} ({}: {})"
        raise ImportError(msg.format(fullname, type(ex), ex)) from ex
    return spec.loader if spec is not None else None
def find_loader ( fullname ) : if fullname . startswith ( '.' ) : msg = "Relative module name {!r} not supported" . format ( fullname ) raise ImportError ( msg ) try : spec = importlib . util . find_spec ( fullname ) except ( ImportError , AttributeError , TypeError , ValueError ) as ex : # This hack fixes an impedance mismatch between pkgutil and # importlib, where the latter raises other errors for cases where # pkgutil previously raised ImportError msg = "Error while finding loader for {!r} ({}: {})" raise ImportError ( msg . format ( fullname , type ( ex ) , ex ) ) from ex return spec . loader if spec is not None else None