@@ -55,7 +55,10 @@ def user_exception(self, frame, (exc_type, exc_value, exc_traceback)):
5555 # This function is called if an exception occurs,
5656 # but only if we are to stop at or just below this level
5757 frame .f_locals ['__exception__' ] = exc_type , exc_value
58- print exc_type + ':' , repr .repr (exc_value )
58+ if type (exc_type ) == type ('' ):
59+ exc_type_name = exc_type
60+ else : exc_type_name = exc_type .__name__
61+ print exc_type_name + ':' , repr .repr (exc_value )
5962 self .interaction (frame , exc_traceback )
6063
6164 # General interaction function
@@ -74,7 +77,10 @@ def default(self, line):
7477 try :
7578 exec (line + '\n ' , globals , locals )
7679 except :
77- print '***' , sys .exc_type + ':' , sys .exc_value
80+ if type (sys .exc_type ) == type ('' ):
81+ exc_type_name = sys .exc_type
82+ else : exc_type_name = sys .exc_type .__name__
83+ print '***' , exc_type_name + ':' , sys .exc_value
7884
7985 # Command definitions, called by cmdloop()
8086 # The argument is the remaining string on the command line
@@ -199,7 +205,10 @@ def do_p(self, arg):
199205 value = eval (arg , self .curframe .f_globals , \
200206 self .curframe .f_locals )
201207 except :
202- print '***' , sys .exc_type + ':' , `sys.exc_value`
208+ if type (sys .exc_type ) == type ('' ):
209+ exc_type_name = sys .exc_type
210+ else : exc_type_name = sys .exc_type .__name__
211+ print '***' , exc_type_name + ':' , `sys.exc_value`
203212 return
204213
205214 print `value`
@@ -254,7 +263,10 @@ def do_whatis(self, arg):
254263 value = eval (arg , self .curframe .f_globals , \
255264 self .curframe .f_locals )
256265 except :
257- print '***' , sys .exc_type + ':' , `sys.exc_value`
266+ if type (sys .exc_type ) == type ('' ):
267+ exc_type_name = sys .exc_type
268+ else : exc_type_name = sys .exc_type .__name__
269+ print '***' , exc_type_name + ':' , `sys.exc_value`
258270 return
259271 code = None
260272 # Is it a function?
@@ -429,14 +441,18 @@ def help_pdb(self):
429441
430442# Simplified interface
431443
432- def run (statement ):
433- Pdb ().run (statement )
444+ def run (statement , globals = None , locals = None ):
445+ Pdb ().run (statement , globals , locals )
446+
447+ def runeval (expression , globals = None , locals = None ):
448+ return Pdb ().runeval (expression , globals , locals )
434449
435450def runctx (statement , globals , locals ):
436- Pdb ().runctx (statement , globals , locals )
451+ # B/W compatibility
452+ run (statement , globals , locals )
437453
438454def runcall (* args ):
439- apply (Pdb ().runcall , args )
455+ return apply (Pdb ().runcall , args )
440456
441457def set_trace ():
442458 Pdb ().set_trace ()
0 commit comments