Commit a558e37e authored by Guido van Rossum's avatar Guido van Rossum

improved prompt format

parent e23b62f2
...@@ -242,7 +242,7 @@ class Bdb: # Basic Debugger ...@@ -242,7 +242,7 @@ class Bdb: # Basic Debugger
# #
def format_stack_entry(self, frame_lineno): def format_stack_entry(self, frame_lineno, lprefix=': '):
import linecache, repr, string import linecache, repr, string
frame, lineno = frame_lineno frame, lineno = frame_lineno
filename = frame.f_code.co_filename filename = frame.f_code.co_filename
...@@ -260,7 +260,7 @@ class Bdb: # Basic Debugger ...@@ -260,7 +260,7 @@ class Bdb: # Basic Debugger
s = s + '->' s = s + '->'
s = s + repr.repr(rv) s = s + repr.repr(rv)
line = linecache.getline(filename, lineno) line = linecache.getline(filename, lineno)
if line: s = s + ': ' + string.strip(line) if line: s = s + lprefix + string.strip(line)
return s return s
# The following two methods can be called by clients to use # The following two methods can be called by clients to use
......
...@@ -10,6 +10,13 @@ import bdb ...@@ -10,6 +10,13 @@ import bdb
import repr import repr
# Interaction prompt line will separate file and call info from code
# text using value of line_prefix string. A newline and arrow may
# be to your liking. You can set it once pdb is imported using the
# command "pdb.line_prefix = '\n% '".
# line_prefix = ': ' # Use this to get the old situation back
line_prefix = '\n-> ' # Probably a better default
class Pdb(bdb.Bdb, cmd.Cmd): class Pdb(bdb.Bdb, cmd.Cmd):
def __init__(self): def __init__(self):
...@@ -55,7 +62,8 @@ class Pdb(bdb.Bdb, cmd.Cmd): ...@@ -55,7 +62,8 @@ class Pdb(bdb.Bdb, cmd.Cmd):
def interaction(self, frame, traceback): def interaction(self, frame, traceback):
self.setup(frame, traceback) self.setup(frame, traceback)
self.print_stack_entry(self.stack[self.curindex]) self.print_stack_entry(self.stack[self.curindex],
line_prefix)
self.cmdloop() self.cmdloop()
self.forget() self.forget()
...@@ -280,13 +288,13 @@ class Pdb(bdb.Bdb, cmd.Cmd): ...@@ -280,13 +288,13 @@ class Pdb(bdb.Bdb, cmd.Cmd):
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
def print_stack_entry(self, frame_lineno): def print_stack_entry(self, frame_lineno, prompt_prefix=''):
frame, lineno = frame_lineno frame, lineno = frame_lineno
if frame is self.curframe: if frame is self.curframe:
print '>', print '>',
else: else:
print ' ', print ' ',
print self.format_stack_entry(frame_lineno) print self.format_stack_entry(frame_lineno, prompt_prefix)
# Help methods (derived from pdb.doc) # Help methods (derived from pdb.doc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment