ast.py 文件源码

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

项目:wuye.vim 作者: zhaoyingnan911 项目源码 文件源码
def parse(source, filename='<string>'):
    # NOTE: the raw string should be given to `compile` function
    if isinstance(source, str):
        source = fscommands.unicode_to_file_data(source)
    source = source.decode()
    if '\r' in source:
        source = source.replace('\r\n', '\n').replace('\r', '\n')
    if not source.endswith('\n'):
        source += '\n'
    try:
        return compile(source.encode(), filename, 'exec', _ast.PyCF_ONLY_AST)
    except (TypeError, ValueError) as e:
        error = SyntaxError()
        error.lineno = 1
        error.filename = filename
        error.msg = str(e)
        raise error
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号