<s> '''<STR_LIT>''' <EOL> import sys <EOL> from . context_manager_type import ContextManagerType <EOL> @ ContextManagerType <EOL> def nested ( * managers ) : <EOL> exits = [ ] <EOL> vars = [ ] <EOL> exc = ( None , None , None ) <EOL> try : <EOL> for mgr in managers : <EOL> exit = mgr . __exit__ <EOL> enter = mgr . __enter__ <EOL> vars . append ( enter ( ) ) <EOL> exits . append ( exit ) <EOL> yield vars <EOL> except : <EOL> exc = sys . exc_info ( ) <EOL> finally : <EOL> while exits : <EOL> exit = exits . pop ( ) <EOL> try : <EOL> if exit ( * exc ) : <EOL> exc = ( None , None , None ) <EOL> except : <EOL> exc = sys . exc_info ( ) <EOL> if exc != ( None , None , None ) : <EOL> raise exc [ <NUM_LIT:1> ] . with_traceback ( exc [ <NUM_LIT:2> ] ) </s>
