def __init__(self, locals=None, encoding=None):
        """Constructor.

        The optional 'locals' argument specifies the dictionary in
        which code will be executed; it defaults to a newly created
        dictionary with key "__name__" set to "__console__" and key
        "__doc__" set to None.

        We include an argument for the outfile to pass to the formatter for it
        to write to.
        """
        if locals is None:
            locals = {"__name__": "__console__", "__doc__": None}
        if encoding is None:
            encoding = getpreferredencoding()
        ReplInterpreter.__init__(self, locals, encoding)

        self.locals = locals
        self.compile = CommandCompiler()

        # typically changed after being instantiated
        # but used when interpreter used corresponding REPL
        def write(err_line):
            """Default stderr handler for tracebacks

            Accepts FmtStrs so interpreters can output them"""
            sys.stderr.write(text_type(err_line))

        self.write = write
        self.outfile = self
Exemplo n.º 2
0
    def __init__(self, locals=None, encoding=None):
        """Constructor.

        We include an argument for the outfile to pass to the formatter for it
        to write to.
        """
        ReplInterpreter.__init__(self, locals, encoding)

        # typically changed after being instantiated
        # but used when interpreter used corresponding REPL
        def write(err_line):
            """Default stderr handler for tracebacks

            Accepts FmtStrs so interpreters can output them"""
            sys.stderr.write(text_type(err_line))

        self.write = write
        self.outfile = self
Exemplo n.º 3
0
    def __init__(self, locals=None, encoding=None):
        """Constructor.

        We include an argument for the outfile to pass to the formatter for it
        to write to.
        """
        ReplInterpreter.__init__(self, locals, encoding)

        # typically changed after being instantiated
        # but used when interpreter used corresponding REPL
        def write(err_line):
            """Default stderr handler for tracebacks

            Accepts FmtStrs so interpreters can output them"""
            sys.stderr.write(text_type(err_line))

        self.write = write
        self.outfile = self
Exemplo n.º 4
0
    def __init__(self, locals=None, encoding=None):
        """Constructor.

        The optional 'locals' argument specifies the dictionary in
        which code will be executed; it defaults to a newly created
        dictionary with key "__name__" set to "__console__" and key
        "__doc__" set to None.

        We include an argument for the outfile to pass to the formatter for it
        to write to.
        """
        if locals is None:
            locals = {"__name__": "__console__", "__doc__": None}
        if encoding is None:
            encoding = getpreferredencoding()
        ReplInterpreter.__init__(self, locals, encoding)

        self.locals = locals
        self.compile = CommandCompiler()

        # typically changed after being instantiated
        self.write = lambda stuff: sys.stderr.write(stuff)
        self.outfile = self