#NEWLINE# @ contextmanager #NEWLINE# def nested( * managers ) : #NEWLINE# #INDENT# exits = [ ] #NEWLINE# vars = [ ] #NEWLINE# exc = ( None , None , None ) #NEWLINE# try : #NEWLINE# #INDENT# for mgr in exit : #NEWLINE# #INDENT# exit = mgr . __exit__ #NEWLINE# enter = mgr . __enter__ #NEWLINE# vars . append ( enter ( ) ) #NEWLINE# exits . append ( exit ) #NEWLINE# #UNINDENT# ( yield vars ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# exc = sys . exc_info ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# while exits : #NEWLINE# #INDENT# exit = exits . pop ( ) #NEWLINE# try : #NEWLINE# #INDENT# if exit ( * exc ) : #NEWLINE# #INDENT# exc = ( None , None , None ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# exc = sys . exc_info ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( exc != ( None , None , None ) ) : #NEWLINE# #INDENT# raise exc [ 1 ]