Exemplo n.º 1
0
    def runcode(self, _code):
        """Execute a code object.

        When an exception occurs, self.showtraceback() is called to
        display a traceback.  All exceptions are caught except
        SystemExit, which is reraised.

        A note about KeyboardInterrupt: this exception may occur
        elsewhere in this code, and may not always be caught.  The
        caller should be prepared to deal with it.

        """
        org_stdout = sys.stdout
        sys.stdout = PseudoFile(self)
        try:
            exec _code in self.locals
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            if code.softspace(sys.stdout, 0):
                print

        sys.stdout = org_stdout
Exemplo n.º 2
0
    def runcode(self, _code):
        """Execute a code object.

        When an exception occurs, self.showtraceback() is called to
        display a traceback. All exceptions are caught except
        SystemExit, which is reraised.

        A note about KeyboardInterrupt: this exception may occur
        elsewhere in this code, and may not always be caught. The
        caller should be prepared to deal with it.

        """
        org_stdout = sys.stdout
        sys.stdout = PseudoFile(self)
        try:
            exec _code in self.locals
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            if code.softspace(sys.stdout, 0):
                print

        sys.stdout = org_stdout
Exemplo n.º 3
0
 def runcode(self, the_code, source, filename='<input>'):
     # code taken from InteractiveInterpreter.runsource in code.py
     try:
         tree = ast.parse(source)
         try:
             expr = ast.parse(source, mode='eval')
         except:
             expr = None
         #todo get this to work for multiple expr's, not just 1:
         if expr and len(tree.body) == 1:
             # _ = expr_value
             tree.body[0] = ast_wrap_in_assn('_', tree.body[0])
             # print _
             underscore = _ast.Name(id="_", ctx=_ast.Load())
             print_node = ast_print_node([_ast.Str(s=' ' * 50), underscore])
             tree.body.append(print_node)
             # play_whatever
             #todo doesn't work for generators yet
             play_whatever_node = ast_call_node('music.play_whatever',
                                                '_',
                                                show_notes=SHOW_NOTES)
             tree.body.append(play_whatever_node)
         #print ast.dump(tree)
         code_obj = compile(tree, '<input>', 'exec')
         exec code_obj in self.locals
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
Exemplo n.º 4
0
	def runcode(self, codeobj):
		"""Execute a code object.

		When an exception occurs, self.showtraceback() is called to
		display a traceback.  All exceptions are caught except
		SystemExit, which is reraised.

		A note about KeyboardInterrupt: this exception may occur
		elsewhere in this code, and may not always be caught.  The
		caller should be prepared to deal with it.
		"""

		try:
			old_display_hook, sys.displayhook = sys.displayhook, self._displayhook
			old_stdout, sys.stdout = sys.stdout, self.outputbuffer
			old_stdin, sys.stdin = sys.stdin, None
			exec codeobj in self.globals, self.locals #pylint: disable-msg=W0122
		except SystemExit:
			raise
		except:
			self.showtraceback()
		else:
			if code.softspace(self.outputbuffer, 0):
				self.outputbuffer.write("\n")
		finally:
			sys.displayhook = old_display_hook
			sys.stdout = old_stdout
			sys.stdin = old_stdin
Exemplo n.º 5
0
 def runcode(self, the_code, source, filename='<input>'):
     # code taken from InteractiveInterpreter.runsource in code.py
     try:
         tree = ast.parse(source)
         try:
             expr = ast.parse(source, mode='eval')
         except:
             expr = None
         #todo get this to work for multiple expr's, not just 1:
         if expr and len(tree.body) == 1:
             # _ = expr_value
             tree.body[0] = ast_wrap_in_assn('_', tree.body[0])
             # print _
             underscore = _ast.Name(id="_", ctx=_ast.Load())
             print_node = ast_print_node([_ast.Str(s=' '*50), underscore])
             tree.body.append(print_node)
             # play_whatever
                 #todo doesn't work for generators yet
             play_whatever_node = ast_call_node('music.play_whatever', '_', show_notes=SHOW_NOTES)
             tree.body.append(play_whatever_node)
         #print ast.dump(tree)
         code_obj = compile(tree, '<input>', 'exec')
         exec code_obj in self.locals
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
Exemplo n.º 6
0
 def runcode(self, code):
     try:
         exec(code, self.locals)
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if softspace is not None and softspace(sys.stdout, 0):
             print
Exemplo n.º 7
0
 def runcode(self, co):
     try:
         self.connection.eval(co, locals=self.locals)
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
Exemplo n.º 8
0
 def runcode(self, codearg):
     try:
         exec codearg in self.globals, self.locals #modified to add support for globals
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
Exemplo n.º 9
0
 def runcode(self, code):
     try:
         exec(code, self.locals)
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if softspace is not None and softspace(sys.stdout, 0):
             print
Exemplo n.º 10
0
 def runcode(self, co):
     try:
         self.connection.eval(co, locals=self.locals)
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
Exemplo n.º 11
0
 def runcode(self, code):
     try:
         exec code in self.locals
     except SystemExit:
         raise
     except Exception:
         print traceback.format_exc()
     else:
         if softspace(sys.stdout, 0):
             print
Exemplo n.º 12
0
 def runcode(self, code):
     try:
         exec code in self.locals
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if softspace(sys.stdout, 0):
             print
Exemplo n.º 13
0
 def runcode(self, code):
     try:
         exec code in self.locals
     except SystemExit:
         raise
     except Exception:
         print traceback.format_exc()
     else:
         if softspace(sys.stdout, 0):
             print
Exemplo n.º 14
0
 def runcode(self, code_):
     # This comes straight from code.py
     try:
         #exec code in self.locals
         exec code_ in self.globals, self.locals
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print()
Exemplo n.º 15
0
 def runcode(self, code_):
     # This comes straight from code.py
     try:
         #exec code in self.locals
         exec code_ in self.globals, self.locals
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
Exemplo n.º 16
0
 def runcode(self, c):
     try:
         exec(c, self.locals)
     except KeyboardInterrupt:
         self.showtraceback()
     except SystemExit:
         # maybe a self.showtraceback() would be good?
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print()
Exemplo n.º 17
0
 def runcode(self, c):
   try:
     exec(c, self.locals)
   except KeyboardInterrupt:
     self.showtraceback()
   except SystemExit:
     # maybe a self.showtraceback() would be good?
     raise
   except:
     self.showtraceback()
   else:
     if code.softspace(sys.stdout, 0):
        print()
 def runcode(self, code):
     try:
         InterpreterKeyController.setEnabled_(True);
         exec code in self.locals
     except SystemExit:
         InterpreterKeyController.setEnabled_(False);
         raise
     except:
         InterpreterKeyController.setEnabled_(False);
         self.showtraceback()
     else:
         InterpreterKeyController.setEnabled_(False);
         if softspace(sys.stdout, 0):
             print
Exemplo n.º 19
0
Arquivo: source.py Projeto: uta8a/ctf
    def runcode(self, _code):
        org_stdout = sys.stdout
        sys.stdout = PseudoFile(self)
        try:
            exec _code in self.locals
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            if code.softspace(sys.stdout, 0):
                print

        sys.stdout = org_stdout
Exemplo n.º 20
0
 def runcode(self, co):
     try:
         exec co in self.locals  # pylint: disable=exec-used
     except SystemExit:
         self.inferior.Cancel()
         raise
     except KeyboardInterrupt:
         raise
     except inferior.PositionError as err:
         print 'PositionError: %s' % err.message
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
Exemplo n.º 21
0
 def runcode(self, c):
     stdout = sys.stdout
     sys.stdout = StringIO()
     try:
         exec c in self.locals
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
     r = sys.stdout.getvalue()
     sys.stdout = stdout
     self.write(r)
Exemplo n.º 22
0
 def runcode(self, co):
     try:
         exec co in self.locals  # pylint: disable=exec-used
     except SystemExit:
         self.inferior.Cancel()
         raise
     except KeyboardInterrupt:
         raise
     except inferior.PositionError as err:
         print "PositionError: %s" % err.message
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
Exemplo n.º 23
0
 def runcode(self, c):
     stdout = sys.stdout
     sys.stdout = StringIO()
     try:
         exec c in self.locals
     except SystemExit:
         raise
     except:
         self.showtraceback()
     else:
         if code.softspace(sys.stdout, 0):
             print
     r = sys.stdout.getvalue()
     sys.stdout = stdout
     self.write(r)
Exemplo n.º 24
0
    def runcode(self, code):
        """Execute a code object.

        When an exception occurs, self.showtraceback() is called to
        display a traceback.  All exceptions are caught except
        SystemExit, which is reraised.

        A note about KeyboardInterrupt: this exception may occur
        elsewhere in this code, and may not always be caught.  The
        caller should be prepared to deal with it.

        """

        self._last_type = self._last_traceback = self._last_value = None
        try:
            exec code in self.locals
        except:
            # Since the exception info may need to travel across the wire, we
            # pack it in right away.  Note that we are abusing the exception
            # value to store a fully formatted traceback, since the stack can
            # not be serialized for network transmission.
            et, ev, tb = sys.exc_info()
            self._last_type = et
            self._last_traceback = tb
            tbinfo = self.tbHandler.text(et, ev, tb)
            # Construct a meaningful traceback message for shipping over the
            # wire.
            buf = pprint.pformat(self.buffer)
            try:
                ename = et.__name__
            except:
                ename = et
            msg = """\
%(ev)s            
***************************************************************************
An exception occurred in an IPython engine while executing user code.

Current execution buffer (lines being run):
%(buf)s

A full traceback from the actual engine:
%(tbinfo)s
***************************************************************************
            """ % locals()
            self._last_value = msg
        else:
            if softspace(sys.stdout, 0):
                print
Exemplo n.º 25
0
 def my_runcode(self, codeobj, source=None):
     """Mostly copied from code.InteractiveInterpreter, but added better
     exception handling.
     """
     session.scriptEvent('start', ('', source))
     try:
         exec_(codeobj, self.globals)
     except NicosInteractiveStop:
         pass
     except KeyboardInterrupt:
         # "immediate stop" chosen
         session.immediateStop()
     except Exception:
         session.scriptEvent('exception', sys.exc_info())
     if hasattr(code, 'softspace') and code.softspace(sys.stdout, 0):
         print()
     session.scriptEvent('finish', None)
    def runcode_global(self, code):
        """ Execute a code object in *only* the global context.

            This method makes it possible to run "from xyz import \*" from
            the command line.  This isn't allowed if a non-dictionary local
            namespace is used.  Note that this method will not work if
            the global dictionary
        """
        try:
            # Use only the globals namespace for execution.
            exec code in self.globals
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            if softspace(sys.stdout, 0):
                print
    def runcode_global(self, code):
        """ Execute a code object in *only* the global context.

            This method makes it possible to run "from xyz import \*" from
            the command line.  This isn't allowed if a non-dictionary local
            namespace is used.  Note that this method will not work if
            the global dictionary
        """
        try:
            # Use only the globals namespace for execution.
            exec code in self.globals
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            if softspace(sys.stdout, 0):
                print
Exemplo n.º 28
0
def runcode(self, code):
    """Execute a code object.

    Our extra-special verson of the runcode method.  We use this when we
    want py_shell_mixin._run_source() to generate real exceptions, and
    not just output to stdout, for example when CodeRunner is executed
    as part of a network.  This runcode() is explicitly called by our local
    runsource() method.
    """
    try:
        exec code in self.locals
    except SystemExit:
        raise
    except:
        raise
        #self.showtraceback()
    else:
        if softspace(sys.stdout, 0):
            print
Exemplo n.º 29
0
def runcode(self, code):
    """Execute a code object.

    Our extra-special verson of the runcode method.  We use this when we
    want py_shell_mixin._run_source() to generate real exceptions, and
    not just output to stdout, for example when CodeRunner is executed
    as part of a network.  This runcode() is explicitly called by our local
    runsource() method.
    """
    try:
        exec code in self.locals
    except SystemExit:
        raise
    except:
        raise
        #self.showtraceback()
    else:
        if softspace(sys.stdout, 0):
            print
    def runcode(self, code):
        """ Execute a code object in the given context.

            This is overloaded from the base class so that we can
            execute in both a global and a local context.  We are using a
            "dictionary-like" object for the locals.  The exec statement
            requires that the globals is a dict.

            The rest of the code is cut/pasted from the base class.
        """
        try:
            # Use both a global and local context.  This is the only change.
            exec code in self.globals, self.locals
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            if softspace(sys.stdout, 0):
                print
    def runcode(self, code):
        """ Execute a code object in the given context.

            This is overloaded from the base class so that we can
            execute in both a global and a local context.  We are using a
            "dictionary-like" object for the locals.  The exec statement
            requires that the globals is a dict.

            The rest of the code is cut/pasted from the base class.
        """
        try:
            # Use both a global and local context.  This is the only change.
            exec code in self.globals, self.locals
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            if softspace(sys.stdout, 0):
                print
Exemplo n.º 32
0
    def runsource(self, source, filename="<input>", symbol="single"):
        if source.strip() == "":
            return False

        try:
            code = self.compile(source, filename, symbol)
        except (OverflowError, SyntaxError, ValueError):
            self.showsyntaxerror(filename)
            return False
        if code is None:
            return True
        # See if it's a valid expression
        try:
            self.compile(source, filename, "eval")
            is_expression = True
        except:
            is_expression = False
        try:

            @stm.atomically
            def result():
                if is_expression:
                    return eval(source, globals(), self.locals)
                else:
                    exec code in globals(), self.locals
                    return None

            if result is not None:
                print result
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            if _code_module.softspace(sys.stdout, 0):
                print

        return False
Exemplo n.º 33
0
    def runcode(self, code):
        """Execute a code object.

        When an exception occurs, self.showtraceback() is called to
        display a traceback.  All exceptions are caught except
        SystemExit, which is reraised.

        A note about KeyboardInterrupt: this exception may occur
        elsewhere in this code, and may not always be caught.  The
        caller should be prepared to deal with it.

        """
        try:
            exec code in self._l_dict, self._g_dict
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            from code import softspace
            import sys            
            if softspace(sys.stdout, 0):
                print
Exemplo n.º 34
0
    def runcode(self, code):
        """Execute a code object.

        When an exception occurs, self.showtraceback() is called to
        display a traceback.  All exceptions are caught except
        SystemExit, which is reraised.

        A note about KeyboardInterrupt: this exception may occur
        elsewhere in this code, and may not always be caught.  The
        caller should be prepared to deal with it.

        """
        try:
            exec code in self._l_dict, self._g_dict
        except SystemExit:
            raise
        except:
            self.showtraceback()
        else:
            from code import softspace
            import sys
            if softspace(sys.stdout, 0):
                print
Exemplo n.º 35
0
    def runcode(self, code):
        """Execute a code object.

        When an exception occurs, self.showtraceback() is called to
        display a traceback.  All exceptions are caught except
        SystemExit, which is reraised.

        A note about KeyboardInterrupt: this exception may occur
        elsewhere in this code, and may not always be caught.  The
        caller should be prepared to deal with it.
        
        Copied directly from code.InteractiveInterpreter, except for
        EmbeddedConsoleExit exceptions.
        """
        try:
            exec code in self.locals
        except (SystemExit, EmbeddedConsoleExit):
            raise
        except:
            self.showtraceback()
        else:
            if softspace(sys.stdout, 0):
                print
Exemplo n.º 36
0
    def runcode(self, code):
        """Execute a code object.

        When an exception occurs, self.showtraceback() is called to
        display a traceback.  All exceptions are caught except
        SystemExit, which is reraised.

        A note about KeyboardInterrupt: this exception may occur
        elsewhere in this code, and may not always be caught.  The
        caller should be prepared to deal with it.

        """
        try:
            exec code in self.locals
        except SystemExit:
            raise
        except:
            #raise # This was hanging the tests.  Need to rethink how we do this.
            self.showtraceback()
            self._tracebackTuple = sys.exc_info()
        else:
            if softspace(sys.stdout, 0):
                print
Exemplo n.º 37
0
def runcode(obj, code_obj):
    """Execute a code object.

    When an exception occurs, self.showtraceback() is called to
    display a traceback.  All exceptions are caught except
    SystemExit, which is reraised.

    A note about KeyboardInterrupt: this exception may occur
    elsewhere in this code, and may not always be caught.  The
    caller should be prepared to deal with it.

    """
    try:
        exec(code_obj, obj.locals, obj.globals)
    except SystemExit:
        raise
    except:
        obj.showtraceback()
    else:
        if code.softspace(sys.stdout, 0):
            print()
            pass
        pass
    return
Exemplo n.º 38
0
def runcode(obj, code_obj):
    """Execute a code object.

    When an exception occurs, self.showtraceback() is called to
    display a traceback.  All exceptions are caught except
    SystemExit, which is reraised.

    A note about KeyboardInterrupt: this exception may occur
    elsewhere in this code, and may not always be caught.  The
    caller should be prepared to deal with it.

    """
    try:
        exec(code_obj, obj.locals, obj.globals)
    except SystemExit:
        raise
    except:
        obj.showtraceback()
    else:
        if code.softspace(sys.stdout, 0):
            print()
            pass
        pass
    return
Exemplo n.º 39
0
         cloud.join(job)
         result = cloud.result(job)
         self.locals.update(result) 
         info = cloud.info(job, ['stderr', 'stdout'])[job]
         sys.stdout.write(info['stdout'])
         sys.stderr.write(info['stderr'])
     except SystemExit:
         raise
     except KeyboardInterrupt:
         raise OperationAborted('Interrupted')
     except cloud.CloudException, e:
         self.showcloudtraceback(e)
     except:
         self.showtraceback()
     else:
         if softspace(sys.stdout, 0):
             print
     
 def showcloudtraceback(self, exception):
     """ Show a traceback from a cloud exception
     """
     tb = exception.parameter.split('\n')
     
     # drop everything up to the execution line 
     while True:
         next = tb.pop(0)
         if 'exec code' in next: 
             break
     
     tb.insert(0, "Traceback (most recent call last):")
     tb = '\n'.join(tb)
Exemplo n.º 40
0
        exception occurs, self.showtraceback() is called to display a
        traceback.
        """
        try:
            res = self.interpreter.run(ast)
            if res not in (None, w_Undefined):
                try:
                    print res.GetValue().ToString(self.interpreter.w_Global)
                except ThrowException, exc:
                    print exc.exception.ToString(self.interpreter.w_Global)
        except SystemExit:
            raise
        except ThrowException, exc:
            self.showtraceback(exc)
        else:
            if code.softspace(sys.stdout, 0):
                print

    def runsource(self, source, filename="<input>"):
        """Parse and run source in the interpreter.

        One of these cases can happen:
        1) The input is incorrect. Prints a nice syntax error message.
        2) The input in incomplete. More input is required. Returns None.
        3) The input is complete. Executes the source code.
        """
        try:
            ast = load_source(source, filename)
        except ParseError, exc:
            if exc.source_pos.i == len(source):
                # Case 2
Exemplo n.º 41
0
    def _run_code(self, code):
        """
        Run the code object in the engine - THIS SHOULD NOT BE CALLED DIRECTLY
        USE run_code() which is thread safe.
        """
        #check for a console
        if self.console is None:
            log.warning('No managing console!')
            raise Exception('No managing console!')

        #set busy flag and send busy messages
        self.busy = True
        
        #published message
        self.publish_msg(   eng_messages.ENGINE_STATE_BUSY+'.'+self.name, 
                            data=(self.debug, self.profile) )
     
        #enable debugger?
        if self.debug is True:
            trace_func = self.debugger
        else:
            trace_func = None

        #enable profiler?
        if self.profile is True:
            profile_func = self.profiler
        else:
            profile_func = None

        #run the code
        try:
            sys.settrace(trace_func)
            sys.setprofile(profile_func)
            exec code in self._userdict
            sys.settrace(None)
            sys.setprofile(None)

        #system exit  - call engine.exit()
        except SystemExit:
            sys.settrace(None)
            sys.setprofile(None)
            self.busy = False
            log.debug('system exit in runnning code')
            self.exit()
            return

        #keyboard interrupt stopped running code
        except KeyboardInterrupt:
            sys.settrace(None)
            sys.setprofile(None)
            self.busy = False

            #engine stopped code in order to exit/or disconnect - do not prompt.
            if self._stop_quiet:
                self._stop_quiet = False
                return

            #user stopped code
            self._stop = False
            if self._isreading: #cancel the read prompt.
                self.send_msg( self.console, eng_messages.CON_PROMPT_STDIN, 
                                data=(self.prompts[1],None,))
            sys.stderr.write('STOP: User forced running code to stop.\n\n')
        
        #other exception - could be an error 1) caused by the engine exiting 2) a different error caused by
        #the KeyboardInterrupt (wxpython doesn't play nice!) or 3) a user code error
        except:
            sys.settrace(None)
            sys.setprofile(None)
            self.busy = False

            #1) engine is exiting/stopping quietly -  probably some error 
            # caused by engine exiting
            if self._stop_quiet:
                self._stop_quiet = False
                log.exception('Exception raised to stop running code? - engine wants to exit.')
                return

            #2) user stopped code
            if self._stop is True:
                self._stop = False
                if self._isreading: #cancel the read prompt.
                    self.send_msg( self.console, eng_messages.CON_PROMPT_STDIN,
                                     data=(self.prompts[1], None,))
                sys.stderr.write('STOP: User forced running code to stop.\n\n')

            #3) error in user code.
            self.compiler.show_traceback()

        #reset internal state flags
        self.busy = False
        self._isreading = False
        if self.debug is True:
            self.debugger.reset()

        #softspace makes the print statement work correctly when using final 
        #comma to supress newlines.
        if softspace(sys.stdout, 0):
            print 

        #If exiting skip the rest.
        if self._stop_quiet is True:
            return

        #send an engine done message
        self.publish_msg(   eng_messages.ENGINE_STATE_DONE+'.'+self.name, 
                            data=(self.debug, self.profile) )
     
        #prompt the console for new command
        try:
            self.send_msg(self.console, eng_messages.CON_PROMPT,
                            (self.prompts[0], False,))
        except:
            log.exception('error ')
            pass
Exemplo n.º 42
0
            res = self.interpreter.run(ast, interactive=True)
            if DEBUG:
                print self.interpreter._code
            if res not in (None, w_Undefined):
                try:
                    if DEBUG:
                        print repr(res)
                    print res.ToString(self.interpreter.w_Global)
                except ThrowException, exc:
                    print exc.exception.ToString(self.interpreter.w_Global)
        except SystemExit:
            raise
        except ThrowException, exc:
            self.showtraceback(exc)
        else:
            if code.softspace(sys.stdout, 0):
                print

    def runsource(self, source, filename="<input>"):
        """Parse and run source in the interpreter.

        One of these cases can happen:
        1) The input is incorrect. Prints a nice syntax error message.
        2) The input in incomplete. More input is required. Returns None.
        3) The input is complete. Executes the source code.
        """
        try:
            ast = load_source(source, filename)
        except ParseError, exc:
            if exc.source_pos.i == len(source):
                # Case 2