Exemplo n.º 1
0
def parse(code, mode, **exception_kwargs):
    try:
        return compiler_parse(code, mode)
    except SyntaxError, e:
        raise exceptions.SyntaxException(
            "(%s) %s (%s)" % (e.__class__.__name__, str(e), repr(code[0:50])),
            **exception_kwargs)
Exemplo n.º 2
0
def parse(code, mode, **exception_kwargs):
    try:
        return compiler_parse(code, mode)
    except SyntaxError, e:
        raise exceptions.SyntaxException(
            "(%s) %s (%s)" % (e.__class__.__name__, str(e), repr(code[0:50])), **exception_kwargs
        )
Exemplo n.º 3
0
def parse(code, mode='exec', **exception_kwargs):
    """Parse an expression into AST"""
    try:
        if _ast:
            return _ast_util.parse(code, '<unknown>', mode)
        else:
            return compiler_parse(code, mode)
    except Exception, e:
        raise exceptions.SyntaxException("(%s) %s (%s)" % (e.__class__.__name__, str(e), repr(code[0:50])), **exception_kwargs)
Exemplo n.º 4
0
def parse(code, mode='exec', **exception_kwargs):
    """Parse an expression into AST"""
    try:
        if _ast:
            return _ast_util.parse(code, '<unknown>', mode)
        else:
            return compiler_parse(code, mode)
    except Exception, e:
        raise exceptions.SyntaxException(
            "(%s) %s (%s)" % (e.__class__.__name__, str(e), repr(code[0:50])),
            **exception_kwargs)
Exemplo n.º 5
0
def parse(code, mode='exec', **exception_kwargs):
    """Parse an expression into AST"""
    

    try:
        if _ast:
            return _ast_util.parse(code, '<unknown>', mode)
        else:
            if isinstance(code, unicode):
                code = code.encode('ascii', 'backslashreplace')
            return compiler_parse(code, mode)
    except Exception, e:
        raise exceptions.SyntaxException("(%s) %s (%s)" % (e.__class__.__name__, str(e), repr(code[0:50])), **exception_kwargs)
Exemplo n.º 6
0
def parse(code, mode='exec', **exception_kwargs):
    """Parse an expression into AST"""

    try:
        if _ast:
            return _ast_util.parse(code, '<unknown>', mode)
        else:
            if isinstance(code, unicode):
                code = code.encode('ascii', 'backslashreplace')
            return compiler_parse(code, mode)
    except Exception, e:
        raise exceptions.SyntaxException(
            "(%s) %s (%r)" % (e.__class__.__name__, e, code[0:50]),
            **exception_kwargs)