Merged revisions 72924 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72924 | georg.brandl | 2009-05-25 23:02:56 +0200 (Mo, 25 Mai 2009) | 6 lines

  Allow multiple context managers in one with statement, as proposed
  in http://codereview.appspot.com/53094 and accepted by Guido.

  The construct is transformed into multiple With AST nodes so that
  there should be no problems with the semantics.
........
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index 61e3067..214143b 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -347,9 +347,10 @@
 usage patterns to be encapsulated for convenient reuse.
 
 .. productionlist::
-   with_stmt: "with" `expression` ["as" `target`] ":" `suite`
+   with_stmt: "with" with_item ("," with_item)* ":" `suite`
+   with_item: `expression` ["as" `target`]
 
-The execution of the :keyword:`with` statement proceeds as follows:
+The execution of the :keyword:`with` statement with one "item" proceeds as follows:
 
 #. The context expression is evaluated to obtain a context manager.
 
@@ -382,6 +383,21 @@
    value from :meth:`__exit__` is ignored, and execution proceeds at the normal
    location for the kind of exit that was taken.
 
+With more than one item, the context managers are processed as if multiple
+:keyword:`with` statements were nested::
+
+   with A() as a, B() as b:
+       suite
+
+is equivalent to ::
+
+   with A() as a:
+       with B() as b:
+           suite
+
+.. versionchanged:: 3.1
+   Support for multiple context expressions.
+
 .. seealso::
 
    :pep:`0343` - The "with" statement