ast.py 文件源码

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

项目:blackmamba 作者: zrzka 项目源码 文件源码
def parse(source, filename='<string>'):
    # NOTE: the raw string should be given to `compile` function
    if isinstance(source, unicode):
        source = fscommands.unicode_to_file_data(source)
    if b'\r' in source:
        source = source.replace(b'\r\n', b'\n').replace(b'\r', b'\n')
    if not source.endswith(b'\n'):
        source += b'\n'
    try:
        return compile(source, 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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号