pdb name truncation
Alex
new_name at mit.edu
Fri Jun 29 15:17:03 EDT 2001
> Is there some setting to get it to expand the ... It's annoying to
> have to restart not under pdb to see what error actually was.
I've had problems with this, too, and your post induced me to finally
fix it instead of work around it. :) (though usually you can get the
complete error by re-executing the line that caused the error from the
pdb prompt, even that's a bit of a pain.)
Stick this in a file my_pdb.py in a directory that'll be in your
sys.path, and do
"from my_pdb import set_trace"
or whatever it is you usually use from there.
If people care, I could submit a patch to fix pdb directly. It'd be a
lot simpler to do this sort of thing if each instance of pdb.Pdb created
its own Repr.repr instance.
HTH
Alex.
import pdb
from repr import Repr
r = Repr()
r.maxother = 2000
r.maxstring = 2000
class my_Pdb(pdb.Pdb):
repr = r.repr
def user_exception(self, frame,
(exc_type, exc_value, exc_traceback)):
"""This function is called if an exception occurs, but only if
we are to stop at or just below this level."""
frame.f_locals['__exception__'] = exc_type, exc_value
if type(exc_type) == type(''):
exc_type_name = exc_type
else: exc_type_name = exc_type.__name__
print exc_type_name + ':', self.repr(exc_value)
self.interaction(frame, exc_traceback)
def run(statement, globals=None, locals=None):
my_Pdb().run(statement, globals, locals)
def runeval(expression, globals=None, locals=None):
return my_Pdb().runeval(expression, globals, locals)
def runcall(*args):
return apply(my_Pdb().runcall, args)
def set_trace():
my_Pdb().set_trace()
def post_mortem(t):
p = my_Pdb()
p.reset()
while t.tb_next is not None:
t = t.tb_next
p.interaction(t.tb_frame, t)
def pm():
post_mortem(sys.last_traceback)
if __name__ == '__main__':
set_trace()
this_name_is_intended_to_produce_a_long_NameError
More information about the Python-list
mailing list