diff --git a/python/helpers/pydev/pydev_console_utils.py b/python/helpers/pydev/pydev_console_utils.py index ef8f68670239..009599cd5145 100644 --- a/python/helpers/pydev/pydev_console_utils.py +++ b/python/helpers/pydev/pydev_console_utils.py @@ -132,9 +132,9 @@ class StdIn(BaseStdIn): return '\n' -class ExecCode: - def __init__(self, code, is_single_line=True): - self.code = code +class CodeFragment: + def __init__(self, text, is_single_line=True): + self.text = text self.is_single_line = is_single_line #======================================================================================================================= @@ -171,7 +171,7 @@ class BaseInterpreterInterface: return self.needMoreForCode(source) - def addExec(self, command): + def addExec(self, codeFragment): original_in = sys.stdin try: help = None @@ -210,7 +210,7 @@ class BaseInterpreterInterface: try: self.startExec() - more = self.doAddExec(command) + more = self.doAddExec(codeFragment) self.finishExec() finally: if help is not None: @@ -236,7 +236,7 @@ class BaseInterpreterInterface: return more, need_input - def doAddExec(self, command): + def doAddExec(self, codeFragment): ''' Subclasses should override. @@ -316,7 +316,7 @@ class BaseInterpreterInterface: def execLine(self, line): try: - self.exec_queue.put(ExecCode(line, True)) + self.exec_queue.put(CodeFragment(line, True)) return self.needMore(self.buffer, line) except: traceback.print_exc() @@ -325,7 +325,7 @@ class BaseInterpreterInterface: def execMultipleLines(self, lines): try: - self.exec_queue.put(ExecCode(lines, False)) + self.exec_queue.put(CodeFragment(lines, False)) return self.needMoreForCode(lines) except: traceback.print_exc() diff --git a/python/helpers/pydev/pydev_ipython_console.py b/python/helpers/pydev/pydev_ipython_console.py index d38127165bea..6a8e0567644e 100644 --- a/python/helpers/pydev/pydev_ipython_console.py +++ b/python/helpers/pydev/pydev_ipython_console.py @@ -39,14 +39,14 @@ class InterpreterInterface(BaseInterpreterInterface): def get_greeting_msg(self): return self.interpreter.get_greeting_msg() - def doAddExec(self, command): + def doAddExec(self, codeFragment): self.notify_about_magic() - if (command.rstrip().endswith('??')): + if (codeFragment.text.rstrip().endswith('??')): print('IPython-->') try: - res = bool(self.interpreter.addExec(command)) + res = bool(self.interpreter.addExec(codeFragment.text)) finally: - if (command.rstrip().endswith('??')): + if (codeFragment.text.rstrip().endswith('??')): print('<--IPython') return res diff --git a/python/helpers/pydev/pydevconsole.py b/python/helpers/pydev/pydevconsole.py index a5f66a80d3e4..f1ca62680c44 100644 --- a/python/helpers/pydev/pydevconsole.py +++ b/python/helpers/pydev/pydevconsole.py @@ -50,6 +50,7 @@ except NameError: # version < 2.3 -- didn't have the True/False builtins setattr(__builtin__, 'False', 0) from pydev_console_utils import BaseInterpreterInterface +from pydev_console_utils import CodeFragment IS_PYTHON_3K = False @@ -120,8 +121,8 @@ class InterpreterInterface(BaseInterpreterInterface): self._input_error_printed = False - def doAddExec(self, command): - command = Command(self.interpreter, command) + def doAddExec(self, codeFragment): + command = Command(self.interpreter, codeFragment) Sync(command) return command.more @@ -153,11 +154,11 @@ def process_exec_queue(interpreter): while 1: try: try: - command = interpreter.exec_queue.get(block=True, timeout=0.05) + codeFragment = interpreter.exec_queue.get(block=True, timeout=0.05) except _queue.Empty: continue - if not interpreter.addExec(command): #TODO: think about locks here + if not interpreter.addExec(codeFragment): #TODO: think about locks here interpreter.buffer = [] except KeyboardInterrupt: interpreter.buffer = [] @@ -308,17 +309,17 @@ def get_completions(text, token, globals, locals): def get_frame(): return interpreterInterface.getFrame() -def exec_expression(expression, globals, locals): +def exec_code(code, globals, locals): interpreterInterface = get_interpreter() interpreterInterface.interpreter.update(globals, locals) - res = interpreterInterface.needMore(None, expression) + res = interpreterInterface.needMore(None, code.text) if res: return True - interpreterInterface.addExec(expression) + interpreterInterface.addExec(code) return False @@ -368,7 +369,7 @@ def consoleExec(thread_id, frame_id, expression): updated_globals.update(frame.f_locals) #locals later because it has precedence over the actual globals if IPYTHON: - return exec_expression(expression, updated_globals, frame.f_locals) + return exec_code(CodeFragment(expression), updated_globals, frame.f_locals) interpreter = ConsoleWriter()