def _extend_object(parent, n, o, otype, fqdn):
from inspect import ismodule, isclass<EOL>pmodule = parent if ismodule(parent) or isclass(parent) else None<EOL>try:<EOL><INDENT>if otype == "<STR_LIT>":<EOL><INDENT>setattr(o.__func__, "<STR_LIT>", None)<EOL><DEDENT>else:<EOL><INDENT>setattr(o, "<STR_LIT>", None)<EOL><DEDENT>fqdn = _fqdn(o, recheck=True, pmodule=pmodule)<EOL>return o<EOL><DEDENT>except (TypeError, AttributeError):<EOL><INDENT>okey = id(o)<EOL>if okey not in _extended_objs:<EOL><INDENT>xobj = _create_extension(o, otype, fqdn, pmodule)<EOL>fqdn = _fqdn(xobj, recheck=True, pmodule=pmodule)<EOL>if xobj is not None:<EOL><INDENT>_extended_objs[okey] = xobj<EOL><DEDENT><DEDENT>try:<EOL><INDENT>setattr(parent, n, _extended_objs[okey])<EOL>return _extended_objs[okey]<EOL><DEDENT>except KeyError: <EOL><INDENT>msg.warn("<STR_LIT>".format(o, otype))<EOL><DEDENT><DEDENT>
Extends the specified object if it needs to be extended. The method
    attempts to add an attribute to the object; if it fails, a new object is
    created that inherits all of `o` attributes, but is now a regular object
    that can have attributes set.

    Args:
        parent: has `n` in its `__dict__` attribute.
        n (str): object name attribute.
        o (list): object instances to be extended.
        otype (str): object types; one of ["classes", "functions", "methods",
          "modules"].
        fqdn (str): fully qualified name of the package that the object belongs
          to.