def _create_extension(o, otype, fqdn, pmodule):
import types<EOL>xdict = {"<STR_LIT>": o,<EOL>"<STR_LIT>": o.__doc__}<EOL>if otype == "<STR_LIT>":<EOL><INDENT>classname = o.__name__<EOL>try:<EOL><INDENT>if fqdn in _explicit_subclasses:<EOL><INDENT>xclass = eval(_explicit_subclasses[fqdn])<EOL>xclass.__acornext__ = o<EOL><DEDENT>else:<EOL><INDENT>xclass = type(classname, (o, ), xdict)<EOL><DEDENT>xclass.__module__ = o.__module__<EOL>return xclass<EOL><DEDENT>except TypeError:<EOL><INDENT>_final_objs.append(id(o))<EOL>return o<EOL><DEDENT><DEDENT>elif (otype in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"] or<EOL>(otype == "<STR_LIT>" and (isinstance(o, types.BuiltinFunctionType) or<EOL>isinstance(o, types.BuiltinMethodType)))):<EOL><INDENT>def xwrapper(*args, **kwargs):<EOL><INDENT>try:<EOL><INDENT>return o(*args, **kwargs)<EOL><DEDENT>except:<EOL><INDENT>targs = list(map(type, args))<EOL>kargs = list(kwargs.keys())<EOL>msg.err("<STR_LIT>".format(o, targs, kargs), <NUM_LIT:2>)<EOL>pass<EOL><DEDENT><DEDENT>for attr, val in xdict.items():<EOL><INDENT>setattr(xwrapper, attr, val)<EOL><DEDENT>failed = False<EOL>setattr(xwrapper, "<STR_LIT>", _safe_getattr(xwrapper))<EOL>failed = not _update_attrs(xwrapper, o, ["<STR_LIT>"])<EOL>if otype in ["<STR_LIT>", "<STR_LIT>"] and inspect.ismodule(pmodule):<EOL><INDENT>if hasattr(o, "<STR_LIT>"): <EOL><INDENT>setattr(xwrapper, "<STR_LIT>", pmodule.__name__)<EOL><DEDENT>elif hasattr(o, "<STR_LIT>") and o.__class__ is not None:<EOL><INDENT>setattr(xwrapper, "<STR_LIT>", pmodule.__name__)<EOL><DEDENT><DEDENT>if not failed:<EOL><INDENT>return xwrapper<EOL><DEDENT><DEDENT>
Creates an extension object to represent `o` that can have attributes
    set, but which behaves identically to the given object.

    Args:
        o: object to create an extension for; no checks are performed to see if
          extension is actually required.
        otype (str): object types; one of ["classes", "functions", "methods",
          "modules"].
        fqdn (str): fully qualified name of the package that the object belongs
          to.
        pmodule: the parent module (or class) that `o` belongs to; used for setting
          the special __module__ attribute.