Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f5a80a4

Browse files
committed
Describe what happens when ``raise C, x'' is called where C is a class
and x is not an instance of C (nor of a class derived of C).
1 parent dbf7956 commit f5a80a4

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

Doc/ref/ref6.tex

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,19 +366,25 @@ \section{The \keyword{raise} statement\label{raise}}
366366
Otherwose, \keyword{raise} evaluates its first expression, which must yield
367367
a string, class, or instance object. If there is a second expression,
368368
this is evaluated, else \code{None} is substituted. If the first
369-
expression is a class object, then the second expression must be an
370-
instance of that class or one of its derivatives. If the first
369+
expression is a class object, then the second expression may be an
370+
instance of that class or one of its derivatives, and then that
371+
instance is raised. If the second expression is not such an instance,
372+
the given class is instantiated. The argument list for the
373+
instantiation is determined as follows: if the second expression is a
374+
tuple, it is used as the argument list; if it is \code{None}, the
375+
argument list is empty; otherwise, the argument list consists of a
376+
single argument which is the second expression. If the first
371377
expression is an instance object, the second expression must be
372378
\code{None}.
373379
\index{exception}
374380
\indexii{raising}{exception}
375381

376-
If the first object is a class or string, it then raises the exception
382+
If the first object is a string, it then raises the exception
377383
identified by the first object, with the second one (or \code{None})
378-
as its parameter. If the first object is an instance, it raises the
379-
exception identified by the class of the object, with the instance as
380-
its parameter (and there should be no second object, or the second
381-
object should be \code{None}).
384+
as its parameter. If the first object is a class or instance,
385+
it raises the exception identified by the class of the instance
386+
determined in the previous step, with the instance as
387+
its parameter.
382388

383389
If a third object is present, and it is not \code{None}, it should be
384390
a traceback object (see section \ref{traceback}), and it is

0 commit comments

Comments
 (0)