added classes as exceptions

This commit is contained in:
Guido van Rossum 1995-02-07 14:37:17 +00:00
parent 626c1e7882
commit eb8b0d20c1
4 changed files with 32 additions and 16 deletions

View file

@ -324,13 +324,20 @@ raise_stmt: "raise" condition ["," condition]
\end{verbatim} \end{verbatim}
\verb@raise@ evaluates its first condition, which must yield \verb@raise@ evaluates its first condition, which must yield
a string object. If there is a second condition, this is evaluated, a string, class, or instance object. If there is a second condition,
else \verb@None@ is substituted. this is evaluated, else \verb@None@ is substituted. If the first
condition is a class object, then the second condition must be an
instance of that class or one of its derivatives. If the first
condition is an instance object, the second condition must be
\verb@None@.
\index{exception} \index{exception}
\indexii{raising}{exception} \indexii{raising}{exception}
It then raises the exception identified by the first object, If the first object is a class or string, it then raises the exception
with the second one (or \verb@None@) as its parameter. identified by the first object, with the second one (or \verb@None@)
as its parameter. If the first object is an instance, it raises the
exception identified by the class of the object, with the instance as
its parameter.
\section{The {\tt break} statement} \section{The {\tt break} statement}
\stindex{break} \stindex{break}

View file

@ -201,10 +201,11 @@ clause, if present, must be last; it matches any exception. For an
except clause with a condition, that condition is evaluated, and the except clause with a condition, that condition is evaluated, and the
clause matches the exception if the resulting object is ``compatible'' clause matches the exception if the resulting object is ``compatible''
with the exception. An object is compatible with an exception if it with the exception. An object is compatible with an exception if it
is either the object that identifies the exception or it is a tuple is either the object that identifies the exception, or (for exceptions
containing an item that is compatible with the exception. Note that that are classes) it is a base class of the exception, or it is a
the object identities must match, i.e. it must be the same object, not tuple containing an item that is compatible with the exception. Note
just an object with the same value. that the object identities must match, i.e. it must be the same
object, not just an object with the same value.
\kwindex{except} \kwindex{except}
If no except clause matches the exception, the search for an exception If no except clause matches the exception, the search for an exception

View file

@ -324,13 +324,20 @@ raise_stmt: "raise" condition ["," condition]
\end{verbatim} \end{verbatim}
\verb@raise@ evaluates its first condition, which must yield \verb@raise@ evaluates its first condition, which must yield
a string object. If there is a second condition, this is evaluated, a string, class, or instance object. If there is a second condition,
else \verb@None@ is substituted. this is evaluated, else \verb@None@ is substituted. If the first
condition is a class object, then the second condition must be an
instance of that class or one of its derivatives. If the first
condition is an instance object, the second condition must be
\verb@None@.
\index{exception} \index{exception}
\indexii{raising}{exception} \indexii{raising}{exception}
It then raises the exception identified by the first object, If the first object is a class or string, it then raises the exception
with the second one (or \verb@None@) as its parameter. identified by the first object, with the second one (or \verb@None@)
as its parameter. If the first object is an instance, it raises the
exception identified by the class of the object, with the instance as
its parameter.
\section{The {\tt break} statement} \section{The {\tt break} statement}
\stindex{break} \stindex{break}

View file

@ -201,10 +201,11 @@ clause, if present, must be last; it matches any exception. For an
except clause with a condition, that condition is evaluated, and the except clause with a condition, that condition is evaluated, and the
clause matches the exception if the resulting object is ``compatible'' clause matches the exception if the resulting object is ``compatible''
with the exception. An object is compatible with an exception if it with the exception. An object is compatible with an exception if it
is either the object that identifies the exception or it is a tuple is either the object that identifies the exception, or (for exceptions
containing an item that is compatible with the exception. Note that that are classes) it is a base class of the exception, or it is a
the object identities must match, i.e. it must be the same object, not tuple containing an item that is compatible with the exception. Note
just an object with the same value. that the object identities must match, i.e. it must be the same
object, not just an object with the same value.
\kwindex{except} \kwindex{except}
If no except clause matches the exception, the search for an exception If no except clause matches the exception, the search for an exception