gdb_utils.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:debugger-utils 作者: spacewander 项目源码 文件源码
def eval_template(template, cmd):
    cmdname = cmd.__name__
    classname = to_classname(cmd.__name__)
    # Use the same technic as namedtuple
    class_definition = template.format(
        cmdname = cmdname,
        docstring = cmd.__doc__ if cmd.__doc__ is not None else '',
        classname = classname
    )
    namespace = dict(__name__='template_%s' % cmdname)
    exec(class_definition, namespace)
    result = namespace[classname]
    result.cmd = cmd
    result._source = class_definition
    try:
        result.__module__ = sys._getframe(1).f_globals.get(
            '__name__', '__main__')
    except (AttributeError, ValueError):
        pass
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号