summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-09-06 14:03:41 (GMT)
committerGeorg Brandl <georg@python.org>2007-09-06 14:03:41 (GMT)
commit0068e2ccb179fbd9d57c37dbb764cd4026c829e5 (patch)
tree56e55af888de114cb78349d100d6aa1d8ff884c4 /Doc
parent105f60ee628842a20f70526f9e994bc8acfaa9c7 (diff)
downloadcpython-0068e2ccb179fbd9d57c37dbb764cd4026c829e5.zip
cpython-0068e2ccb179fbd9d57c37dbb764cd4026c829e5.tar.gz
cpython-0068e2ccb179fbd9d57c37dbb764cd4026c829e5.tar.bz2
New exception catching syntax.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/reference/compound_stmts.rst17
1 files changed, 8 insertions, 9 deletions
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index bd55bc9..2837838 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -219,13 +219,13 @@ for a group of statements:
.. productionlist::
try_stmt: try1_stmt | try2_stmt
try1_stmt: "try" ":" `suite`
- : ("except" [`expression` ["," `target`]] ":" `suite`)+
+ : ("except" [`expression` ["as" `target`]] ":" `suite`)+
: ["else" ":" `suite`]
: ["finally" ":" `suite`]
try2_stmt: "try" ":" `suite`
: "finally" ":" `suite`
-The :keyword:`except` clause(s) specify one or more exception handlers. When no
+The :keyword:`except` clause(s) specify one or more exception handlers. When no
exception occurs in the :keyword:`try` clause, no exception handler is executed.
When an exception occurs in the :keyword:`try` suite, a search for an exception
handler is started. This search inspects the except clauses in turn until one
@@ -245,12 +245,12 @@ the new exception in the surrounding code and on the call stack (it is treated
as if the entire :keyword:`try` statement raised the exception).
When a matching except clause is found, the exception is assigned to the target
-specified in that except clause, if present, and the except clause's suite is
-executed. All except clauses must have an executable block. When the end of
-this block is reached, execution continues normally after the entire try
-statement. (This means that if two nested handlers exist for the same
-exception, and the exception occurs in the try clause of the inner handler, the
-outer handler will not handle the exception.)
+specified after the ``as`` keyword in that except clause, if present, and the
+except clause's suite is executed. All except clauses must have an executable
+block. When the end of this block is reached, execution continues normally
+after the entire try statement. (This means that if two nested handlers exist
+for the same exception, and the exception occurs in the try clause of the inner
+handler, the outer handler will not handle the exception.)
.. index::
module: sys
@@ -545,4 +545,3 @@ instance variables with different implementation details.
.. [#] Currently, control "flows off the end" except in the case of an exception or the
execution of a :keyword:`return`, :keyword:`continue`, or :keyword:`break`
statement.
-