Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_with.Nested Class Reference
Inheritance diagram for test.test_with.Nested:
Inheritance graph
[legend]
Collaboration diagram for test.test_with.Nested:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __enter__
def __exit__

Public Attributes

 managers
 entered
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Definition at line 56 of file test_with.py.


Constructor & Destructor Documentation

def test.test_with.Nested.__init__ (   self,
  managers 
)

Reimplemented in test.test_with.MockNested.

Definition at line 58 of file test_with.py.

00058 
00059     def __init__(self, *managers):
00060         self.managers = managers
00061         self.entered = None

Here is the caller graph for this function:


Member Function Documentation

Reimplemented in test.test_with.MockNested.

Definition at line 62 of file test_with.py.

00062 
00063     def __enter__(self):
00064         if self.entered is not None:
00065             raise RuntimeError("Context is not reentrant")
00066         self.entered = deque()
00067         vars = []
00068         try:
00069             for mgr in self.managers:
00070                 vars.append(mgr.__enter__())
00071                 self.entered.appendleft(mgr)
00072         except:
00073             if not self.__exit__(*sys.exc_info()):
00074                 raise
00075         return vars

def test.test_with.Nested.__exit__ (   self,
  exc_info 
)

Reimplemented in test.test_with.MockNested.

Definition at line 76 of file test_with.py.

00076 
00077     def __exit__(self, *exc_info):
00078         # Behave like nested with statements
00079         # first in, last out
00080         # New exceptions override old ones
00081         ex = exc_info
00082         for mgr in self.entered:
00083             try:
00084                 if mgr.__exit__(*ex):
00085                     ex = (None, None, None)
00086             except:
00087                 ex = sys.exc_info()
00088         self.entered = None
00089         if ex is not exc_info:
00090             raise ex[0](ex[1]).with_traceback(ex[2])
00091 

Here is the caller graph for this function:


Member Data Documentation

Definition at line 60 of file test_with.py.

Definition at line 59 of file test_with.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


The documentation for this class was generated from the following file: