def METHOD_NAME(locals, msg=None, exitmsg=None, poll_func=None):
    saved_display = sys.displayhook
    try:
        def display(val):
            if isinstance(val, int) and not isinstance(val, bool):
                builtins._ = val
                print(hex(val))
            elif callable(val):
                val()
            else:
                saved_display(val)
        sys.displayhook = display
        # convenience
        locals["h"] = hex
        locals["sysreg"] = sysreg
        if "proxy" in locals and "p" not in locals:
            locals["p"] = locals["proxy"]
        if "utils" in locals and "u" not in locals:
            locals["u"] = locals["utils"]
        for obj_name in ("iface", "p", "u"):
            obj = locals.get(obj_name)
            obj_class = type(obj)
            if obj is None:
                continue
            for attr in dir(obj_class):
                if attr in locals or attr.startswith('_'):
                    continue
                member = getattr(obj_class, attr)
                if callable(member) and not isinstance(member, property):
                    cmd = getattr(obj, attr)
                    locals[attr] = cmd
        for attr in dir(sysreg):
            locals[attr] = getattr(sysreg, attr)
        locals['help'] = help_cmd
        locals['debug'] = debug_cmd
        for obj_name in locals.keys():
            obj = locals.get(obj_name)
            if obj is None or obj_name.startswith('_'):
                continue
            if callable(obj) and not isinstance(obj, property):
                try:
                    desc = obj_name + str(signature(obj))
                except:
                    continue
                qn = obj.__qualname__
                if qn.find('.') > 0:
                    a = qn.split('.')
                    if a[0] not in subcmd_list:
                        subcmd_list[a[0]] = {}
                    if a[0] not in cmd_list:
                        cmd_list[a[0]] = 1
                    else:
                        cmd_list[a[0]] += 1
                    clist = subcmd_list[a[0]] 
                else:
                    clist = None
                if locals[obj_name].__doc__:
                    desc += " - " + locals[obj_name].__doc__
                    cmd_list[obj_name] = desc
                if isinstance(clist, dict):
                    clist[obj_name] = desc
        con = HistoryConsole(locals)
        con.poll_func = poll_func
        try:
            con.interact(msg, exitmsg)
        except ExitConsole as e:
            if len(e.args):
                return e.args[0]
            else:
                return
        finally:
            con.save_history()
    finally:
        sys.displayhook = saved_display