def compile_command(source, filename="<input>", symbol="single"):
    r"""Compile a command and determine whether it is incomplete.

    Arguments:

    source -- the source string; may contain \n characters
    filename -- optional filename from which source was read; default
                "<input>"
    symbol -- optional grammar start symbol; "single" (default) or "eval"

    Return value / exceptions raised:

    - Return a code object if the command is complete and valid
    - Return None if the command is incomplete
    - Raise SyntaxError, ValueError or OverflowError if the command is a
      syntax error (OverflowError and ValueError can be produced by
      malformed literals).
    """
    if symbol not in ['single','eval']:
        raise ValueError,"symbol arg must be either single or eval"
    symbol = CompileMode.getMode(symbol)
    return Py.compile_command_flags(source,filename,symbol,Py.getCompilerFlags(),0)
Beispiel #2
0
def compile_command(source, filename="<input>", symbol="single"):
    r"""Compile a command and determine whether it is incomplete.

    Arguments:

    source -- the source string; may contain \n characters
    filename -- optional filename from which source was read; default
                "<input>"
    symbol -- optional grammar start symbol; "single" (default) or "eval"

    Return value / exceptions raised:

    - Return a code object if the command is complete and valid
    - Return None if the command is incomplete
    - Raise SyntaxError, ValueError or OverflowError if the command is a
      syntax error (OverflowError and ValueError can be produced by
      malformed literals).
    """
    if symbol not in ['single','eval']:
        raise ValueError,"symbol arg must be either single or eval"
    symbol = CompileMode.getMode(symbol)
    return Py.compile_command_flags(source,filename,symbol,Py.getCompilerFlags(),0)
Beispiel #3
0
 def __call__(self, source, filename, symbol):
     symbol = CompileMode.getMode(symbol)
     return Py.compile_flags(source, filename, symbol, self._cflags)
 def __call__(self, source, filename, symbol):
     symbol = CompileMode.getMode(symbol)
     return Py.compile_flags(source, filename, symbol, self._cflags)