diff options
author | Guido van Rossum <guido@python.org> | 1995-02-27 13:13:40 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-02-27 13:13:40 (GMT) |
commit | 5e38b6fda1d4e2822ac72e1f643f251bd0f3175b (patch) | |
tree | 4a86a9f4be277dd15b9957a15d768a7b09966e3e /Lib/pdb.py | |
parent | 051ab123b465685e714668099c0a6dd86de5673b (diff) | |
download | cpython-5e38b6fda1d4e2822ac72e1f643f251bd0f3175b.zip cpython-5e38b6fda1d4e2822ac72e1f643f251bd0f3175b.tar.gz cpython-5e38b6fda1d4e2822ac72e1f643f251bd0f3175b.tar.bz2 |
handle class exceptions; added runeval; made runctx obsolete
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-x | Lib/pdb.py | 32 |
1 files changed, 24 insertions, 8 deletions
@@ -55,7 +55,10 @@ class Pdb(bdb.Bdb, cmd.Cmd): # 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 - print exc_type + ':', repr.repr(exc_value) + if type(exc_type) == type(''): + exc_type_name = exc_type + else: exc_type_name = exc_type.__name__ + print exc_type_name + ':', repr.repr(exc_value) self.interaction(frame, exc_traceback) # General interaction function @@ -74,7 +77,10 @@ class Pdb(bdb.Bdb, cmd.Cmd): try: exec(line + '\n', globals, locals) except: - print '***', sys.exc_type + ':', sys.exc_value + if type(sys.exc_type) == type(''): + exc_type_name = sys.exc_type + else: exc_type_name = sys.exc_type.__name__ + print '***', exc_type_name + ':', sys.exc_value # Command definitions, called by cmdloop() # The argument is the remaining string on the command line @@ -199,7 +205,10 @@ class Pdb(bdb.Bdb, cmd.Cmd): value = eval(arg, self.curframe.f_globals, \ self.curframe.f_locals) except: - print '***', sys.exc_type + ':', `sys.exc_value` + if type(sys.exc_type) == type(''): + exc_type_name = sys.exc_type + else: exc_type_name = sys.exc_type.__name__ + print '***', exc_type_name + ':', `sys.exc_value` return print `value` @@ -254,7 +263,10 @@ class Pdb(bdb.Bdb, cmd.Cmd): value = eval(arg, self.curframe.f_globals, \ self.curframe.f_locals) except: - print '***', sys.exc_type + ':', `sys.exc_value` + if type(sys.exc_type) == type(''): + exc_type_name = sys.exc_type + else: exc_type_name = sys.exc_type.__name__ + print '***', exc_type_name + ':', `sys.exc_value` return code = None # Is it a function? @@ -429,14 +441,18 @@ class Pdb(bdb.Bdb, cmd.Cmd): # Simplified interface -def run(statement): - Pdb().run(statement) +def run(statement, globals=None, locals=None): + Pdb().run(statement, globals, locals) + +def runeval(expression, globals=None, locals=None): + return Pdb().runeval(expression, globals, locals) def runctx(statement, globals, locals): - Pdb().runctx(statement, globals, locals) + # B/W compatibility + run(statement, globals, locals) def runcall(*args): - apply(Pdb().runcall, args) + return apply(Pdb().runcall, args) def set_trace(): Pdb().set_trace() |