Commit a79c1616 authored by Guido van Rossum's avatar Guido van Rossum

* ref3.tex: added cross-ref to try statement for exc handler.

* ref7.tex: added description of sys.exc_{type,value,traceback}.
* lib5.tex: rect.intersect is different now!
parent 574b7bf2
...@@ -532,12 +532,13 @@ the code object). ...@@ -532,12 +532,13 @@ the code object).
\ttindex{f_lineno} \ttindex{f_lineno}
\ttindex{f_lasti} \ttindex{f_lasti}
\item[Traceback objects] \item[Traceback objects] \label{traceback}
Traceback objects represent a stack trace of an exception. A Traceback objects represent a stack trace of an exception. A
traceback object is created when an exception occurs. When the search traceback object is created when an exception occurs. When the search
for an exception handler unwinds the execution stack, at each unwound for an exception handler unwinds the execution stack, at each unwound
level a traceback object is inserted in front of the current level a traceback object is inserted in front of the current
traceback. When an exception handler is entered, the stack trace is traceback. When an exception handler is entered
(see also section \ref{try}), the stack trace is
made available to the program as \verb\sys.exc_traceback\. When the made available to the program as \verb\sys.exc_traceback\. When the
program contains no suitable handler, the stack trace is written program contains no suitable handler, the stack trace is written
(nicely formatted) to the standard error stream; if the interpreter is (nicely formatted) to the standard error stream; if the interpreter is
......
...@@ -172,7 +172,7 @@ for x in a[:]: ...@@ -172,7 +172,7 @@ for x in a[:]:
if x < 0: a.remove(x) if x < 0: a.remove(x)
\end{verbatim} \end{verbatim}
\section{The {\tt try} statement} \section{The {\tt try} statement} \label{try}
\stindex{try} \stindex{try}
The \verb\try\ statement specifies exception handlers and/or cleanup The \verb\try\ statement specifies exception handlers and/or cleanup
...@@ -222,6 +222,19 @@ statement. (This means that if two nested handlers exist for the same ...@@ -222,6 +222,19 @@ statement. (This means that if two nested handlers exist for the same
exception, and the exception occurs in the try clause of the inner exception, and the exception occurs in the try clause of the inner
handler, the outer handler will not handle the exception.) handler, the outer handler will not handle the exception.)
Before an except clause's suite is executed, details about the
exception are assigned to three variables in the \verb\sys\ module:
\verb\sys.exc_type\ receives the object identifying the exception;
\verb\sys.exc_value\ receives the exception's parameter;
\verb\sys.exc_traceback\ receives a traceback object (see section
\ref{traceback}) identifying the point in the program where the
exception occurred.
\bimodindex{sys}
\ttindex{exc_type}
\ttindex{exc_value}
\ttindex{exc_traceback}
\obindex{traceback}
The \verb\try...finally\ form specifies a `cleanup' handler. The The \verb\try...finally\ form specifies a `cleanup' handler. The
\verb\try\ clause is executed. When no exception occurs, the \verb\try\ clause is executed. When no exception occurs, the
\verb\finally\ clause is executed. When an exception occurs in the \verb\finally\ clause is executed. When an exception occurs in the
......
...@@ -532,12 +532,13 @@ the code object). ...@@ -532,12 +532,13 @@ the code object).
\ttindex{f_lineno} \ttindex{f_lineno}
\ttindex{f_lasti} \ttindex{f_lasti}
\item[Traceback objects] \item[Traceback objects] \label{traceback}
Traceback objects represent a stack trace of an exception. A Traceback objects represent a stack trace of an exception. A
traceback object is created when an exception occurs. When the search traceback object is created when an exception occurs. When the search
for an exception handler unwinds the execution stack, at each unwound for an exception handler unwinds the execution stack, at each unwound
level a traceback object is inserted in front of the current level a traceback object is inserted in front of the current
traceback. When an exception handler is entered, the stack trace is traceback. When an exception handler is entered
(see also section \ref{try}), the stack trace is
made available to the program as \verb\sys.exc_traceback\. When the made available to the program as \verb\sys.exc_traceback\. When the
program contains no suitable handler, the stack trace is written program contains no suitable handler, the stack trace is written
(nicely formatted) to the standard error stream; if the interpreter is (nicely formatted) to the standard error stream; if the interpreter is
......
...@@ -172,7 +172,7 @@ for x in a[:]: ...@@ -172,7 +172,7 @@ for x in a[:]:
if x < 0: a.remove(x) if x < 0: a.remove(x)
\end{verbatim} \end{verbatim}
\section{The {\tt try} statement} \section{The {\tt try} statement} \label{try}
\stindex{try} \stindex{try}
The \verb\try\ statement specifies exception handlers and/or cleanup The \verb\try\ statement specifies exception handlers and/or cleanup
...@@ -222,6 +222,19 @@ statement. (This means that if two nested handlers exist for the same ...@@ -222,6 +222,19 @@ statement. (This means that if two nested handlers exist for the same
exception, and the exception occurs in the try clause of the inner exception, and the exception occurs in the try clause of the inner
handler, the outer handler will not handle the exception.) handler, the outer handler will not handle the exception.)
Before an except clause's suite is executed, details about the
exception are assigned to three variables in the \verb\sys\ module:
\verb\sys.exc_type\ receives the object identifying the exception;
\verb\sys.exc_value\ receives the exception's parameter;
\verb\sys.exc_traceback\ receives a traceback object (see section
\ref{traceback}) identifying the point in the program where the
exception occurred.
\bimodindex{sys}
\ttindex{exc_type}
\ttindex{exc_value}
\ttindex{exc_traceback}
\obindex{traceback}
The \verb\try...finally\ form specifies a `cleanup' handler. The The \verb\try...finally\ form specifies a `cleanup' handler. The
\verb\try\ clause is executed. When no exception occurs, the \verb\try\ clause is executed. When no exception occurs, the
\verb\finally\ clause is executed. When an exception occurs in the \verb\finally\ clause is executed. When an exception occurs in the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment