diff options
author | Guido van Rossum <guido@python.org> | 1995-02-07 14:37:17 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-02-07 14:37:17 (GMT) |
commit | eb8b0d20c116766cb5a1aae275177c02526c5fd4 (patch) | |
tree | f4db62fce30b2e993bd26d8602fadbe144f4bbdb | |
parent | 626c1e7882841777615345c5df7b6d3a44554d08 (diff) | |
download | cpython-eb8b0d20c116766cb5a1aae275177c02526c5fd4.zip cpython-eb8b0d20c116766cb5a1aae275177c02526c5fd4.tar.gz cpython-eb8b0d20c116766cb5a1aae275177c02526c5fd4.tar.bz2 |
added classes as exceptions
-rw-r--r-- | Doc/ref/ref6.tex | 15 | ||||
-rw-r--r-- | Doc/ref/ref7.tex | 9 | ||||
-rw-r--r-- | Doc/ref6.tex | 15 | ||||
-rw-r--r-- | Doc/ref7.tex | 9 |
4 files changed, 32 insertions, 16 deletions
diff --git a/Doc/ref/ref6.tex b/Doc/ref/ref6.tex index 70e1a68..f0f318f 100644 --- a/Doc/ref/ref6.tex +++ b/Doc/ref/ref6.tex @@ -324,13 +324,20 @@ raise_stmt: "raise" condition ["," condition] \end{verbatim} \verb@raise@ evaluates its first condition, which must yield -a string object. If there is a second condition, this is evaluated, -else \verb@None@ is substituted. +a string, class, or instance object. If there is a second condition, +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} \indexii{raising}{exception} -It then raises the exception identified by the first object, -with the second one (or \verb@None@) as its parameter. +If the first object is a class or string, it then raises the exception +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} \stindex{break} diff --git a/Doc/ref/ref7.tex b/Doc/ref/ref7.tex index f099ae5..196215a 100644 --- a/Doc/ref/ref7.tex +++ b/Doc/ref/ref7.tex @@ -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 clause matches the exception if the resulting object is ``compatible'' 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 -containing an item that is compatible with the exception. Note that -the object identities must match, i.e. it must be the same object, not -just an object with the same value. +is either the object that identifies the exception, or (for exceptions +that are classes) it is a base class of the exception, or it is a +tuple containing an item that is compatible with the exception. Note +that the object identities must match, i.e. it must be the same +object, not just an object with the same value. \kwindex{except} If no except clause matches the exception, the search for an exception diff --git a/Doc/ref6.tex b/Doc/ref6.tex index 70e1a68..f0f318f 100644 --- a/Doc/ref6.tex +++ b/Doc/ref6.tex @@ -324,13 +324,20 @@ raise_stmt: "raise" condition ["," condition] \end{verbatim} \verb@raise@ evaluates its first condition, which must yield -a string object. If there is a second condition, this is evaluated, -else \verb@None@ is substituted. +a string, class, or instance object. If there is a second condition, +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} \indexii{raising}{exception} -It then raises the exception identified by the first object, -with the second one (or \verb@None@) as its parameter. +If the first object is a class or string, it then raises the exception +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} \stindex{break} diff --git a/Doc/ref7.tex b/Doc/ref7.tex index f099ae5..196215a 100644 --- a/Doc/ref7.tex +++ b/Doc/ref7.tex @@ -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 clause matches the exception if the resulting object is ``compatible'' 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 -containing an item that is compatible with the exception. Note that -the object identities must match, i.e. it must be the same object, not -just an object with the same value. +is either the object that identifies the exception, or (for exceptions +that are classes) it is a base class of the exception, or it is a +tuple containing an item that is compatible with the exception. Note +that the object identities must match, i.e. it must be the same +object, not just an object with the same value. \kwindex{except} If no except clause matches the exception, the search for an exception |