mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
improved prompt format
This commit is contained in:
parent
e23b62f288
commit
a558e37eb4
2 changed files with 13 additions and 5 deletions
|
|
@ -242,7 +242,7 @@ def get_stack(self, f, t):
|
|||
|
||||
#
|
||||
|
||||
def format_stack_entry(self, frame_lineno):
|
||||
def format_stack_entry(self, frame_lineno, lprefix=': '):
|
||||
import linecache, repr, string
|
||||
frame, lineno = frame_lineno
|
||||
filename = frame.f_code.co_filename
|
||||
|
|
@ -260,7 +260,7 @@ def format_stack_entry(self, frame_lineno):
|
|||
s = s + '->'
|
||||
s = s + repr.repr(rv)
|
||||
line = linecache.getline(filename, lineno)
|
||||
if line: s = s + ': ' + string.strip(line)
|
||||
if line: s = s + lprefix + string.strip(line)
|
||||
return s
|
||||
|
||||
# The following two methods can be called by clients to use
|
||||
|
|
|
|||
14
Lib/pdb.py
14
Lib/pdb.py
|
|
@ -10,6 +10,13 @@
|
|||
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):
|
||||
|
||||
def __init__(self):
|
||||
|
|
@ -55,7 +62,8 @@ def user_exception(self, frame, (exc_type, exc_value, exc_traceback)):
|
|||
|
||||
def interaction(self, 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.forget()
|
||||
|
||||
|
|
@ -280,13 +288,13 @@ def print_stack_trace(self):
|
|||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
def print_stack_entry(self, frame_lineno):
|
||||
def print_stack_entry(self, frame_lineno, prompt_prefix=''):
|
||||
frame, lineno = frame_lineno
|
||||
if frame is self.curframe:
|
||||
print '>',
|
||||
else:
|
||||
print ' ',
|
||||
print self.format_stack_entry(frame_lineno)
|
||||
print self.format_stack_entry(frame_lineno, prompt_prefix)
|
||||
|
||||
|
||||
# Help methods (derived from pdb.doc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue