#NEWLINE# def __exit__( self , * exc_details ) : #NEWLINE# #INDENT# received_exc = ( exc_details [ 0 ] is not None ) #NEWLINE# frame_exc = sys . exc_info ( ) [ 1 ] #NEWLINE# def _fix_exception_context( new_exc , old_exc ) : #NEWLINE# #INDENT# while 1 : #NEWLINE# #INDENT# exc_context = new_exc . __context__ #NEWLINE# if ( exc_context in ( None , frame_exc ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# new_exc = exc_context #NEWLINE# #UNINDENT# new_exc . __context__ = old_exc #NEWLINE# #UNINDENT# suppressed_exc = False #NEWLINE# pending_raise = False #NEWLINE# while self . _exit_callbacks : #NEWLINE# #INDENT# cb = self . _exit_callbacks . pop ( ) #NEWLINE# try : #NEWLINE# #INDENT# if cb ( * exc_details ) : #NEWLINE# #INDENT# suppressed_exc = True #NEWLINE# pending_raise = False #NEWLINE# exc_details = ( None , None , None ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# new_exc_details = sys . exc_info ( ) #NEWLINE# _fix_exception_context ( new_exc_details [ 1 ] , exc_details [ 1 ] ) #NEWLINE# pending_raise = True #NEWLINE# exc_details = new_exc_details #NEWLINE# #UNINDENT# #UNINDENT# if pending_raise : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# fixed_ctx = exc_details [ 1 ] . __context__ #NEWLINE# raise exc_details [ 1 ] #NEWLINE# #UNINDENT# except BaseException : #NEWLINE# #INDENT# exc_details [ 1 ] . __context__ = fixed_ctx #NEWLINE# raise #NEWLINE# #UNINDENT# #UNINDENT# return ( received_exc and suppressed_exc )