Back to index

python3.2  3.2.2
Classes | Functions | Variables
codeop Namespace Reference

Classes

class  Compile
class  CommandCompiler

Functions

def _maybe_compile
def _compile
def compile_command

Variables

list _features
list __all__ = ["compile_command", "Compile", "CommandCompiler"]
int PyCF_DONT_IMPLY_DEDENT = 0x200

Function Documentation

def codeop._compile (   source,
  filename,
  symbol 
) [private]

Definition at line 101 of file codeop.py.

00101 
00102 def _compile(source, filename, symbol):
00103     return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)

Here is the call graph for this function:

Here is the caller graph for this function:

def codeop._maybe_compile (   compiler,
  source,
  filename,
  symbol 
) [private]

Definition at line 68 of file codeop.py.

00068 
00069 def _maybe_compile(compiler, source, filename, symbol):
00070     # Check for source consisting of only blank lines and comments
00071     for line in source.split("\n"):
00072         line = line.strip()
00073         if line and line[0] != '#':
00074             break               # Leave it alone
00075     else:
00076         if symbol != "eval":
00077             source = "pass"     # Replace it with a 'pass' statement
00078 
00079     err = err1 = err2 = None
00080     code = code1 = code2 = None
00081 
00082     try:
00083         code = compiler(source, filename, symbol)
00084     except SyntaxError as err:
00085         pass
00086 
00087     try:
00088         code1 = compiler(source + "\n", filename, symbol)
00089     except SyntaxError as e:
00090         err1 = e
00091 
00092     try:
00093         code2 = compiler(source + "\n\n", filename, symbol)
00094     except SyntaxError as e:
00095         err2 = e
00096 
00097     if code:
00098         return code
00099     if not code1 and repr(err1) == repr(err2):
00100         raise err1

Here is the caller graph for this function:

def codeop.compile_command (   source,
  filename = "<input>",
  symbol = "single" 
)

Definition at line 104 of file codeop.py.

00104 
00105 def compile_command(source, filename="<input>", symbol="single"):
00106     r"""Compile a command and determine whether it is incomplete.
00107 
00108     Arguments:
00109 
00110     source -- the source string; may contain \n characters
00111     filename -- optional filename from which source was read; default
00112                 "<input>"
00113     symbol -- optional grammar start symbol; "single" (default) or "eval"
00114 
00115     Return value / exceptions raised:
00116 
00117     - Return a code object if the command is complete and valid
00118     - Return None if the command is incomplete
00119     - Raise SyntaxError, ValueError or OverflowError if the command is a
00120       syntax error (OverflowError and ValueError can be produced by
00121       malformed literals).
00122     """
00123     return _maybe_compile(_compile, source, filename, symbol)

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

list codeop.__all__ = ["compile_command", "Compile", "CommandCompiler"]

Definition at line 64 of file codeop.py.

Initial value:
00001 [getattr(__future__, fname)
00002              for fname in __future__.all_feature_names]

Definition at line 61 of file codeop.py.

Definition at line 66 of file codeop.py.