예제 #1
0
def _run_eval_string(source, filename, cmd):
    # Adopted from PyPy's main.py
    try:
        ws = py_space.newtext

        pycode = compilecode(py_space, source, filename or '<string>', cmd)

        mainmodule = ensure__main__(py_space)
        if not isinstance(mainmodule, Module):
            print 'mainmodule not an instance of Module.'
            return
        w_globals = mainmodule.w_dict

        py_space.setitem(w_globals, ws('__builtins__'), py_space.builtin)
        if filename is not None:
            py_space.setitem(w_globals, ws('__file__'), ws(filename))

        retval = pycode.exec_code(py_space, w_globals, w_globals)
        if eval:
            return retval
        else:
            return

    except OperationError as operationerr:
        operationerr.record_interpreter_traceback()
        raise
예제 #2
0
파일: utils.py 프로젝트: swipswaps/RSqueak
def _run_eval_string(source, filename, cmd):
    # Adopted from PyPy's main.py
    try:
        ws = py_space.newtext

        pycode = compilecode(py_space, source, filename or '<string>', cmd)

        mainmodule = ensure__main__(py_space)
        if not isinstance(mainmodule, Module):
            print 'mainmodule not an instance of Module.'
            return
        w_globals = mainmodule.w_dict

        py_space.setitem(w_globals, ws('__builtins__'), py_space.builtin)
        if filename is not None:
            py_space.setitem(w_globals, ws('__file__'), ws(filename))

        retval = pycode.exec_code(py_space, w_globals, w_globals)
        if eval:
            return retval
        else:
            return

    except OperationError as operationerr:
        operationerr.record_interpreter_traceback()
        raise
예제 #3
0
    def __init__(self, objspace, verbose=0, completer=False):
        code.InteractiveConsole.__init__(self)
        self.space = objspace
        self.verbose = verbose
        space = self.space
        self.console_compiler_flags = 0

        mainmodule = main.ensure__main__(space)
        self.w_globals = mainmodule.w_dict
        space.setitem(self.w_globals, space.wrap('__builtins__'), space.builtin)
        if completer:
            self.enable_command_line_completer()

        # forbidden:
        #space.exec_("__pytrace__ = 0", self.w_globals, self.w_globals)
        space.setitem(self.w_globals, space.wrap('__pytrace__'),space.wrap(0))
        self.tracelevel = 0
        self.console_locals = {}
예제 #4
0
    def __init__(self, objspace, verbose=0, completer=False):
        code.InteractiveConsole.__init__(self)
        self.space = objspace
        self.verbose = verbose
        space = self.space
        self.console_compiler_flags = 0

        mainmodule = main.ensure__main__(space)
        self.w_globals = mainmodule.w_dict
        space.setitem(self.w_globals, space.wrap('__builtins__'), space.builtin)
        if completer:
            self.enable_command_line_completer()

        # forbidden:
        #space.exec_("__pytrace__ = 0", self.w_globals, self.w_globals)
        space.setitem(self.w_globals, space.wrap('__pytrace__'),space.wrap(0))
        self.tracelevel = 0
        self.console_locals = {}