diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2006-05-03 13:17:49 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2006-05-03 13:17:49 (GMT) |
commit | d8accb32a54d2157c50e6b8de883373ec15f52c8 (patch) | |
tree | f2262e7f13e501be8b26ca99b19ee84cfeab97e9 /Doc/lib/libcontextlib.tex | |
parent | afd5e63e243b600e5344a34760d9e6565dafe1a9 (diff) | |
download | cpython-d8accb32a54d2157c50e6b8de883373ec15f52c8.zip cpython-d8accb32a54d2157c50e6b8de883373ec15f52c8.tar.gz cpython-d8accb32a54d2157c50e6b8de883373ec15f52c8.tar.bz2 |
Get rid of a couple more context object references, fix some markup and clarify what happens when a generator context function swallows an exception.
Diffstat (limited to 'Doc/lib/libcontextlib.tex')
-rw-r--r-- | Doc/lib/libcontextlib.tex | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Doc/lib/libcontextlib.tex b/Doc/lib/libcontextlib.tex index f28bdd0..72bf537 100644 --- a/Doc/lib/libcontextlib.tex +++ b/Doc/lib/libcontextlib.tex @@ -13,7 +13,7 @@ Functions provided: \begin{funcdesc}{contextmanager}{func} This function is a decorator that can be used to define a factory -function for \keyword{with} statement context objects, without +function for \keyword{with} statement context managers, without needing to create a class or separate \method{__enter__()} and \method{__exit__()} methods. @@ -52,9 +52,10 @@ occurred. Thus, you can use a the error (if any), or ensure that some cleanup takes place. If an exception is trapped merely in order to log it or to perform some action (rather than to suppress it entirely), the generator must -reraise that exception. Otherwise the \keyword{with} statement will -treat the exception as having been handled, and resume execution with -the statement immediately following the \keyword{with} statement. +reraise that exception. Otherwise the generator context manager will +indicate to the \keyword{with} statement that the exception has been +handled, and execution will resume with the statement immediately +following the \keyword{with} statement. \end{funcdesc} \begin{funcdesc}{nested}{mgr1\optional{, mgr2\optional{, ...}}} @@ -81,9 +82,9 @@ with A as X: Note that if the \method{__exit__()} method of one of the nested context managers indicates an exception should be suppressed, no exception information will be passed to any remaining outer context -objects. Similarly, if the \method{__exit__()} method of one of the -nested context managers raises an exception, any previous exception -state will be lost; the new exception will be passed to the +managers. Similarly, if the \method{__exit__()} method of one of the +nested managers raises an exception, any previous exception state will +be lost; the new exception will be passed to the \method{__exit__()} methods of any remaining outer context managers. In general, \method{__exit__()} methods should avoid raising exceptions, and in particular they should not re-raise a |