Fix w.r.t. exception tuples.

This commit is contained in:
Georg Brandl 2008-10-07 16:04:41 +00:00
parent 55027bb2f1
commit dfbb060c4c
1 changed files with 9 additions and 1 deletions

View File

@ -83,7 +83,7 @@ to ::
The use of ``as`` in place of the comma token means that ::
except AttributeError, os.error:
except (AttributeError, os.error):
can be clearly understood as a tuple of exception classes. This new
syntax was first proposed by Greg Ewing [#firstproposal]_ and
@ -93,6 +93,14 @@ Further, the restriction of the token following ``as`` from ``test``
to ``NAME`` means that only valid identifiers can be used as
``except`` targets.
Note that the grammar above always requires parenthesized tuples as
exception clases. That way, the ambiguous ::
except A, B:
which would mean different things in Python 2.x and 3.x -- leading to
hard-to-catch bugs -- cannot legally occur in 3.x code.
Semantic Changes
================