(module)
Return True if the module is special module that cannot be imported by its
    name.
Return True if the module is special module that cannot be imported by its
    name.
Return True if the module is special module that cannot be imported by its name .
def _is_dynamic(module):
    """
    Return True if the module is special module that cannot be imported by its
    name.
    """
    # Quick check: module that have __file__ attribute are not dynamic modules.
    if hasattr(module, "__file__"):
        return False

    if hasattr(module, "__spec__"):
        if module.__spec__ is not None:
            return False

        # In PyPy, Some built-in modules such as _codecs can have their
        # __spec__ attribute set to None despite being imported.  For such
        # modules, the ``_find_spec`` utility of the standard library is used.
        parent_name = module.__name__.rpartition(".")[0]
        if parent_name:  # pragma: no cover
            # This code handles the case where an imported package (and not
            # module) remains with __spec__ set to None. It is however untested
            # as no package in the PyPy stdlib has __spec__ set to None after
            # it is imported.
            try:
                parent = sys.modules[parent_name]
            except KeyError:
                msg = "parent {!r} not in sys.modules"
                raise ImportError(msg.format(parent_name))
            else:
                pkgpath = parent.__path__
        else:
            pkgpath = None
        return _find_spec(module.__name__, pkgpath, module) is None

    else:
        # Backward compat for Python 2
        import imp

        try:
            path = None
            for part in module.__name__.split("."):
                if path is not None:
                    path = [path]
                f, path, description = imp.find_module(part, path)
                if f is not None:
                    f.close()
        except ImportError:
            return True
        return False
def _is_dynamic ( module ) : # Quick check: module that have __file__ attribute are not dynamic modules. if hasattr ( module , "__file__" ) : return False if hasattr ( module , "__spec__" ) : if module . __spec__ is not None : return False # In PyPy, Some built-in modules such as _codecs can have their # __spec__ attribute set to None despite being imported.  For such # modules, the ``_find_spec`` utility of the standard library is used. parent_name = module . __name__ . rpartition ( "." ) [ 0 ] if parent_name : # pragma: no cover # This code handles the case where an imported package (and not # module) remains with __spec__ set to None. It is however untested # as no package in the PyPy stdlib has __spec__ set to None after # it is imported. try : parent = sys . modules [ parent_name ] except KeyError : msg = "parent {!r} not in sys.modules" raise ImportError ( msg . format ( parent_name ) ) else : pkgpath = parent . __path__ else : pkgpath = None return _find_spec ( module . __name__ , pkgpath , module ) is None else : # Backward compat for Python 2 import imp try : path = None for part in module . __name__ . split ( "." ) : if path is not None : path = [ path ] f , path , description = imp . find_module ( part , path ) if f is not None : f . close ( ) except ImportError : return True return False