'Import the object given by *self.modname* and *self.objpath* and set
it as *self.object*.
Returns True if successful, False if an error occurred.'

def import_object(self):

    if self.objpath:
        logger.debug('[autodoc]    from    %s    import    %s', self.modname, '.'.join(self.objpath))
    import_hook = _MockImporter(self.env.config.autodoc_mock_imports)
    try:
        logger.debug('[autodoc]    import    %s', self.modname)
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore', category=ImportWarning)
            with logging.skip_warningiserror((not self.env.config.autodoc_warningiserror)):
                __import__(self.modname)
        parent = None
        obj = self.module = sys.modules[self.modname]
        logger.debug('[autodoc]    =>    %r', obj)
        for part in self.objpath:
            parent = obj
            logger.debug('[autodoc]    getattr(_,    %r)', part)
            obj = self.get_attr(obj, part)
            logger.debug('[autodoc]    =>    %r', obj)
            self.object_name = part
        self.parent = parent
        self.object = obj
        return True
    except (Exception, SystemExit) as e:
        if self.objpath:
            errmsg = ('autodoc:    failed    to    import    %s    %r    from    module    %r' % (self.objtype, '.'.join(self.objpath), self.modname))
        else:
            errmsg = ('autodoc:    failed    to    import    %s    %r' % (self.objtype, self.fullname))
        if isinstance(e, SystemExit):
            errmsg += (';    the    module    executes    module    level    statement    ' + 'and    it    might    call    sys.exit().')
        else:
            errmsg += (';    the    following    exception    was    raised:\n%s' % traceback.format_exc())
        if PY2:
            errmsg = errmsg.decode('utf-8')
        logger.debug(errmsg)
        self.directive.warn(errmsg)
        self.env.note_reread()
        return False
    finally:
        import_hook.disable()
