mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
Fix input() and help() functions in IPython debug console (PY-19853)
This commit is contained in:
@@ -189,10 +189,13 @@ class BaseInterpreterInterface:
|
||||
|
||||
return self.need_more_for_code(self.buffer.text)
|
||||
|
||||
def create_std_in(self):
|
||||
return StdIn(self, self.host, self.client_port)
|
||||
def create_std_in(self, debugger=None, original_std_in=None):
|
||||
if debugger is None:
|
||||
return StdIn(self, self.host, self.client_port)
|
||||
else:
|
||||
return DebugConsoleStdIn(dbg=debugger, original_stdin=original_std_in)
|
||||
|
||||
def add_exec(self, code_fragment):
|
||||
def add_exec(self, code_fragment, debugger=None):
|
||||
original_in = sys.stdin
|
||||
try:
|
||||
help = None
|
||||
@@ -210,7 +213,7 @@ class BaseInterpreterInterface:
|
||||
|
||||
more = False
|
||||
try:
|
||||
sys.stdin = self.create_std_in()
|
||||
sys.stdin = self.create_std_in(debugger, original_in)
|
||||
try:
|
||||
if help is not None:
|
||||
#This will enable the help() function to work.
|
||||
|
||||
@@ -1331,7 +1331,7 @@ class InternalConsoleExec(InternalThreadCommand):
|
||||
#don't trace new threads created by console command
|
||||
disable_trace_thread_modules()
|
||||
|
||||
result = pydevconsole.console_exec(self.thread_id, self.frame_id, self.expression)
|
||||
result = pydevconsole.console_exec(self.thread_id, self.frame_id, self.expression, dbg)
|
||||
xml = "<xml>"
|
||||
xml += pydevd_vars.var_to_xml(result, "")
|
||||
xml += "</xml>"
|
||||
|
||||
@@ -374,7 +374,7 @@ def get_completions(text, token, globals, locals):
|
||||
# Debugger integration
|
||||
#===============================================================================
|
||||
|
||||
def exec_code(code, globals, locals):
|
||||
def exec_code(code, globals, locals, debugger):
|
||||
interpreterInterface = get_interpreter()
|
||||
interpreterInterface.interpreter.update(globals, locals)
|
||||
|
||||
@@ -383,7 +383,7 @@ def exec_code(code, globals, locals):
|
||||
if res:
|
||||
return True
|
||||
|
||||
interpreterInterface.add_exec(code)
|
||||
interpreterInterface.add_exec(code, debugger)
|
||||
|
||||
return False
|
||||
|
||||
@@ -443,7 +443,7 @@ class ConsoleWriter(InteractiveInterpreter):
|
||||
tblist = tb = None
|
||||
sys.stderr.write(''.join(lines))
|
||||
|
||||
def console_exec(thread_id, frame_id, expression):
|
||||
def console_exec(thread_id, frame_id, expression, dbg):
|
||||
"""returns 'False' in case expression is partially correct
|
||||
"""
|
||||
frame = pydevd_vars.find_frame(thread_id, frame_id)
|
||||
@@ -458,7 +458,7 @@ def console_exec(thread_id, frame_id, expression):
|
||||
updated_globals.update(frame.f_locals) #locals later because it has precedence over the actual globals
|
||||
|
||||
if IPYTHON:
|
||||
need_more = exec_code(CodeFragment(expression), updated_globals, frame.f_locals)
|
||||
need_more = exec_code(CodeFragment(expression), updated_globals, frame.f_locals, dbg)
|
||||
if not need_more:
|
||||
pydevd_save_locals.save_locals(frame)
|
||||
return need_more
|
||||
|
||||
Reference in New Issue
Block a user