diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index dd8161a31e..d7f8031f45 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -12,6 +12,43 @@ exit = -1 done = 0 cont = 1 +def print_exc_plus(): + """ + Print the usual traceback information, followed by a listing of all the + local variables in each frame. + """ + import sys + import traceback + + tb = sys.exc_info()[2] + while 1: + if not tb.tb_next: + break + tb = tb.tb_next + stack = [] + f = tb.tb_frame + while f: + stack.append(f) + f = f.f_back + stack.reverse() + traceback.print_exc() + print "Locals by frame, innermost last" + for frame in stack: + print + print "Frame %s in %s at line %s" % (frame.f_code.co_name, + frame.f_code.co_filename, + frame.f_lineno) + for key, value in frame.f_locals.items(): + print "\t%20s = " % key, + #We have to be careful not to cause a new error in our error + #printer! Calling str() on an unknown object could cause an + #error we don't want. + try: + print value + except: + print "" + + # Store the global clock globalClock = ClockObject.getGlobalClock() @@ -460,6 +497,8 @@ class TaskManager: except KeyboardInterrupt: self.stop() except: + # self.stop() + # print_exc_plus() raise def stop(self):