Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a558e37

Browse files
committed
improved prompt format
1 parent e23b62f commit a558e37

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

Lib/bdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def get_stack(self, f, t):
242242

243243
#
244244

245-
def format_stack_entry(self, frame_lineno):
245+
def format_stack_entry(self, frame_lineno, lprefix=': '):
246246
import linecache, repr, string
247247
frame, lineno = frame_lineno
248248
filename = frame.f_code.co_filename
@@ -260,7 +260,7 @@ def format_stack_entry(self, frame_lineno):
260260
s = s + '->'
261261
s = s + repr.repr(rv)
262262
line = linecache.getline(filename, lineno)
263-
if line: s = s + ': ' + string.strip(line)
263+
if line: s = s + lprefix + string.strip(line)
264264
return s
265265

266266
# The following two methods can be called by clients to use

Lib/pdb.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
import repr
1111

1212

13+
# Interaction prompt line will separate file and call info from code
14+
# text using value of line_prefix string. A newline and arrow may
15+
# be to your liking. You can set it once pdb is imported using the
16+
# command "pdb.line_prefix = '\n% '".
17+
# line_prefix = ': ' # Use this to get the old situation back
18+
line_prefix = '\n-> ' # Probably a better default
19+
1320
class Pdb(bdb.Bdb, cmd.Cmd):
1421

1522
def __init__(self):
@@ -55,7 +62,8 @@ def user_exception(self, frame, (exc_type, exc_value, exc_traceback)):
5562

5663
def interaction(self, frame, traceback):
5764
self.setup(frame, traceback)
58-
self.print_stack_entry(self.stack[self.curindex])
65+
self.print_stack_entry(self.stack[self.curindex],
66+
line_prefix)
5967
self.cmdloop()
6068
self.forget()
6169

@@ -280,13 +288,13 @@ def print_stack_trace(self):
280288
except KeyboardInterrupt:
281289
pass
282290

283-
def print_stack_entry(self, frame_lineno):
291+
def print_stack_entry(self, frame_lineno, prompt_prefix=''):
284292
frame, lineno = frame_lineno
285293
if frame is self.curframe:
286294
print '>',
287295
else:
288296
print ' ',
289-
print self.format_stack_entry(frame_lineno)
297+
print self.format_stack_entry(frame_lineno, prompt_prefix)
290298

291299

292300
# Help methods (derived from pdb.doc)

0 commit comments

Comments
 (0)