@Trace
  def FindAndLoadModule(self,
                        submodule,
                        submodule_fullname,
                        search_path):
    """Finds and loads a module, loads it, and adds it to the module dictionary.

    Args:
      submodule: Name of the module to import (e.g., baz).
      submodule_fullname: Full name of the module to import (e.g., foo.bar.baz).
      search_path: Path to use for searching for this submodule. For top-level
        modules this should be None; otherwise it should be the __path__
        attribute from the parent package.

    Returns:
      A new module instance that has been inserted into the module dictionary
      supplied to __init__.

    Raises:
      ImportError exception if the module could not be loaded for whatever
      reason (e.g., missing, not allowed).
    """
    module = self._imp.new_module(submodule_fullname)

    if submodule_fullname == 'thread':
      module.__dict__.update(self._dummy_thread.__dict__)
      module.__name__ = 'thread'
    elif submodule_fullname == 'cPickle':
      module.__dict__.update(self._pickle.__dict__)
      module.__name__ = 'cPickle'
    elif submodule_fullname == 'os':
      module.__dict__.update(self._os.__dict__)
    elif submodule_fullname == 'ssl':
      pass
    elif self.StubModuleExists(submodule_fullname):
      module = self.ImportStubModule(submodule_fullname)
    else:
      source_file, pathname, description = self.FindModuleRestricted(submodule, submodule_fullname, search_path)
      module = self.LoadModuleRestricted(submodule_fullname,
                                         source_file,
                                         pathname,
                                         description)




    if (getattr(module, '__path__', None) is not None and
        search_path != self._app_code_path):
      try:
        app_search_path = os.path.join(self._app_code_path,
                                       *(submodule_fullname.split('.')[:-1]))
        source_file, pathname, description = self.FindModuleRestricted(submodule,
                                    submodule_fullname,
                                    [app_search_path])


        module.__path__.append(pathname)
      except __HOLE__, e:
        pass




    module.__loader__ = self
    self.FixModule(module)
    if submodule_fullname not in self._module_dict:
      self._module_dict[submodule_fullname] = module
    if submodule_fullname != submodule:
      parent_module = self._module_dict.get(
          submodule_fullname[:-len(submodule) - 1])


      if parent_module and not hasattr(parent_module, submodule):
        setattr(parent_module, submodule, module)

    if submodule_fullname == 'os':








      os_path_name = module.path.__name__
      os_path = self.FindAndLoadModule(os_path_name, os_path_name, search_path)


      self._module_dict['os.path'] = os_path
      module.__dict__['path'] = os_path

    return module
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/dev_appserver_import_hook.py/HardenedModulesHook.FindAndLoadModule