prune_cfg.py 文件源码

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

项目:peval 作者: fjarri 项目源码 文件源码
def filter_block(node_list):
    """
    Remove no-op code (``pass``), or any code after
    an unconditional jump (``return``, ``break``, ``continue``, ``raise``).
    """
    if len(node_list) == 1:
        return node_list

    new_list = []
    for node in node_list:
        if type(node) == ast.Pass:
            continue
        new_list.append(node)
        if type(node) in (ast.Return, ast.Break, ast.Continue, ast.Raise):
            break
    if len(new_list) == len(node_list):
        return node_list
    else:
        return new_list
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号