Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pudb/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1853,9 +1853,21 @@ def run_external_cmdline(w, size, key):

self.update_var_view()

def run_internal_shell(w, size, key, first_time=[True]):
frame = self.debugger.curframe
if first_time: self.screen.stop()
import pudb.shell as sh
histfile, ns = sh.readline_init(frame.f_globals, frame.f_locals)
ret = toggle_cmdline_focus(w, size, key)
sh.readline_fini(histfile)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to call readline_init/readline_fini here at all?

if first_time:
self.screen.start()
first_time.pop()
return ret

def run_cmdline(w, size, key):
if CONFIG["shell"] == "internal":
return toggle_cmdline_focus(w, size, key)
return run_internal_shell(w, size, key)
else:
return run_external_cmdline(w, size, key)

Expand Down
28 changes: 17 additions & 11 deletions pudb/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,7 @@ def __delitem__(self, key):

custom_shell_dict = {}


def run_classic_shell(globals, locals, first_time=[True]):
if first_time:
banner = "Hit Ctrl-D to return to PuDB."
first_time.pop()
else:
banner = ""

def readline_init(globals, locals):
ns = SetPropagatingDict([locals, globals], locals)

from pudb.settings import get_save_config_path
Expand All @@ -98,14 +91,27 @@ def run_classic_shell(globals, locals, first_time=[True]):
except IOError:
pass

return hist_file, ns

def readline_fini(hist_file):
if HAVE_READLINE:
readline.write_history_file(hist_file)

def run_classic_shell(globals, locals, first_time=[True]):
if first_time:
banner = "Hit Ctrl-D to return to PuDB."
first_time.pop()
else:
banner = ""

hist_file, ns = readline_init(globals, locals)

from code import InteractiveConsole
cons = InteractiveConsole(ns)

cons.interact(banner)

if HAVE_READLINE:
readline.write_history_file(hist_file)

readline_fini(hist_file)

def run_bpython_shell(globals, locals):
ns = SetPropagatingDict([locals, globals], locals)
Expand Down