Index: pdb.py =================================================================== --- pdb.py (revision 74707) +++ pdb.py (working copy) @@ -183,11 +183,15 @@ def user_return(self, frame, return_value): """This function is called when a return trap is set here.""" + if self._wait_for_mainpyfile: + return frame.f_locals['__return__'] = return_value print >>self.stdout, '--Return--' self.interaction(frame, None) def user_exception(self, frame, exc_info): + if self._wait_for_mainpyfile: + return exc_type, exc_value, exc_traceback = exc_info """This function is called if an exception occurs, but only if we are to stop at or just below this level."""