Commit db40afaa authored by Fred Drake's avatar Fred Drake

Small clarifications when referring to the sys.exc_* variables so that

readers are not given the wrong impression that they should be using those
on a regualar basis.
This closes SF bug #585598.
parent fd83374f
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
This module provides a standard interface to extract, format and print This module provides a standard interface to extract, format and print
stack traces of Python programs. It exactly mimics the behavior of stack traces of Python programs. It exactly mimics the behavior of
the Python interpreter when it prints a stack trace. This is useful the Python interpreter when it prints a stack trace. This is useful
when you want to print stack traces under program control, e.g. in a when you want to print stack traces under program control, such as in a
``wrapper'' around the interpreter. ``wrapper'' around the interpreter.
The module uses traceback objects --- this is the object type The module uses traceback objects --- this is the object type that is
that is stored in the variables \code{sys.exc_traceback} and stored in the variables \code{sys.exc_traceback} (deprecated) and
\code{sys.last_traceback} and returned as the third item from \code{sys.last_traceback} and returned as the third item from
\function{sys.exc_info()}. \function{sys.exc_info()}.
\obindex{traceback} \obindex{traceback}
...@@ -35,22 +35,22 @@ This differs from \function{print_tb()} in the ...@@ -35,22 +35,22 @@ This differs from \function{print_tb()} in the
following ways: (1) if \var{traceback} is not \code{None}, it prints a following ways: (1) if \var{traceback} is not \code{None}, it prints a
header \samp{Traceback (most recent call last):}; (2) it prints the header \samp{Traceback (most recent call last):}; (2) it prints the
exception \var{type} and \var{value} after the stack trace; (3) if exception \var{type} and \var{value} after the stack trace; (3) if
\var{type} is \exception{SyntaxError} and \var{value} has the appropriate \var{type} is \exception{SyntaxError} and \var{value} has the
format, it prints the line where the syntax error occurred with a appropriate format, it prints the line where the syntax error occurred
caret indicating the approximate position of the error. with a caret indicating the approximate position of the error.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{print_exc}{\optional{limit\optional{, file}}} \begin{funcdesc}{print_exc}{\optional{limit\optional{, file}}}
This is a shorthand for `\code{print_exception(sys.exc_type,} This is a shorthand for \code{print_exception(sys.exc_type,
\code{sys.exc_value,} \code{sys.exc_traceback,} \var{limit}\code{,} sys.exc_value, sys.exc_traceback, \var{limit}, \var{file})}. (In
\var{file}\code{)}'. (In fact, it uses \code{sys.exc_info()} to fact, it uses \function{sys.exc_info()} to retrieve the same
retrieve the same information in a thread-safe way.) information in a thread-safe way instead of using the deprecated
variables.)
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{print_last}{\optional{limit\optional{, file}}} \begin{funcdesc}{print_last}{\optional{limit\optional{, file}}}
This is a shorthand for `\code{print_exception(sys.last_type,} This is a shorthand for \code{print_exception(sys.last_type,
\code{sys.last_value,} \code{sys.last_traceback,} \var{limit}\code{,} sys.last_value, sys.last_traceback, \var{limit}, \var{file})}.
\var{file}\code{)}'.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{print_stack}{\optional{f\optional{, limit\optional{, file}}}} \begin{funcdesc}{print_stack}{\optional{f\optional{, limit\optional{, file}}}}
...@@ -93,8 +93,8 @@ Format the exception part of a traceback. The arguments are the ...@@ -93,8 +93,8 @@ Format the exception part of a traceback. The arguments are the
exception type and value such as given by \code{sys.last_type} and exception type and value such as given by \code{sys.last_type} and
\code{sys.last_value}. The return value is a list of strings, each \code{sys.last_value}. The return value is a list of strings, each
ending in a newline. Normally, the list contains a single string; ending in a newline. Normally, the list contains a single string;
however, for \code{SyntaxError} exceptions, it contains several lines however, for \exception{SyntaxError} exceptions, it contains several
that (when printed) display detailed information about where the lines that (when printed) display detailed information about where the
syntax error occurred. The message indicating which exception syntax error occurred. The message indicating which exception
occurred is the always last string in the list. occurred is the always last string in the list.
\end{funcdesc} \end{funcdesc}
......
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