1# ticket: 536 2 3__doc__ = """ 4>>> inner_result 5['ENTER'] 6>>> result # doctest: +ELLIPSIS 7['ENTER', ...EXIT (<...ValueError...>,...ValueError..., <traceback object at ...)...] 8 9>>> inner_result_no_exc 10['ENTER'] 11>>> result_no_exc 12['ENTER', 'EXIT (None, None, None)'] 13""" 14 15class ContextManager(object): 16 def __init__(self, result): 17 self.result = result 18 def __enter__(self): 19 self.result.append("ENTER") 20 def __exit__(self, *values): 21 self.result.append("EXIT %r" % (values,)) 22 return True 23 24result_no_exc = [] 25 26with ContextManager(result_no_exc) as c: 27 inner_result_no_exc = result_no_exc[:] 28 29result = [] 30 31with ContextManager(result) as c: 32 inner_result = result[:] 33 raise ValueError('TEST') 34 35