

def _importAndCheckStack(importName):
    '\n    Import the given name as a module, then walk the stack to determine whether\n    the failure was the module not existing, or some code in the module (for\n    example a dependent import) failing.  This can be helpful to determine\n    whether any actual application code was run.  For example, to distiguish\n    administrative error (entering the wrong module name), from programmer\n    error (writing buggy code in a module that fails to import).\n\n    @param importName: The name of the module to import.\n    @type importName: C{str}\n    @raise Exception: if something bad happens.  This can be any type of\n        exception, since nobody knows what loading some arbitrary code might\n        do.\n    @raise _NoModuleFound: if no module was found.\n    '
    try:
        return __import__(importName)
    except ImportError:
        (excType, excValue, excTraceback) = sys.exc_info()
        while excTraceback:
            execName = excTraceback.tb_frame.f_globals['__name__']
            if ((execName is None) or (execName == importName)):
                reraise(excValue, excTraceback)
            excTraceback = excTraceback.tb_next
        raise _NoModuleFound()

dataset/ETHPy150Open Julian/jsonschema/jsonschema/_reflect.py _importAndCheckStack/original