gdesk.core.interpreter module

class gdesk.core.interpreter.Interpreter(workspace=None, thread_id=None)

Bases: object

async_break()
async_system_exit()
compile_source(source, filename='<input>', symbol='auto')

Compile and run some source in the interpreter.

Arguments are as for compile_command().

One several things can happen:

1) The input is incorrect; compile_command() raised an exception (SyntaxError or OverflowError). A syntax traceback will be printed by calling the showsyntaxerror() method.

2) The input is incomplete, and more input is required; compile_command() returned None. Nothing happens.

3) The input is complete; compile_command() returned a code object. The code is executed by calling self.runcode() (which also handles run-time exceptions, except for SystemExit).

The return value is True in case 2, False in the other cases (unless an exception is raised). The return value can be used to decide whether to use sys.ps1 or sys.ps2 to prompt the next line.

eval_expression(expression)

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.

exec_code(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.

get_code_frames(back)
showsyntaxerror(filename=None)

Display the syntax error that just occurred.

This doesn’t display a stack trace because there isn’t one.

If a filename is given, it is stuffed in the exception instead of what was there before (because Python’s parser always uses “<string>” when reading from a string).

The output is written by self.write(), below.

showtraceback()

Display the exception that just occurred.

We remove the first stack item because it is our own code.

The output is written by self.write(), below.

use_one_command(cmd)
write_error(text)
class gdesk.core.interpreter.QueueInterpreter(shell, cqs, gui_proxy=None, console_id=None)

Bases: object

commandLoop()
control()
control_loop()
static create_and_interact(shell, cqs, gui_proxy=None, console_id=None)
execute()
get_current_locals(back=5)
get_current_trace(back=50)
interact()
register_thread(tid, cqs)
set_console_mode(mode)
system_tracer(*args)
unregister_thread()
exception gdesk.core.interpreter.SyncBreaked

Bases: Exception

gdesk.core.interpreter.async_break(thread_id)
gdesk.core.interpreter.async_raise(thread_id, exctype)

Raise the exception to the thread tid, performs cleanup if needed.

gdesk.core.interpreter.async_system_exit(thread_id)