diff options
author | Ka-Ping Yee <ping@zesty.ca> | 2001-03-23 02:46:52 (GMT) |
---|---|---|
committer | Ka-Ping Yee <ping@zesty.ca> | 2001-03-23 02:46:52 (GMT) |
commit | b5c5132d1ac526dc97f8c51ef12299bde791a807 (patch) | |
tree | 68d6dbc1068e0a16051530564b789148cfb516cb /Doc | |
parent | 37f7b38eb6247564c00c8a355ab12268e8486c4e (diff) | |
download | cpython-b5c5132d1ac526dc97f8c51ef12299bde791a807.zip cpython-b5c5132d1ac526dc97f8c51ef12299bde791a807.tar.gz cpython-b5c5132d1ac526dc97f8c51ef12299bde791a807.tar.bz2 |
Add sys.excepthook.
Update docstring and library reference section on 'sys' module.
New API PyErr_Display, just for displaying errors, called by excepthook.
Uncaught exceptions now call sys.excepthook; if that fails, we fall back
to calling PyErr_Display directly.
Also comes with sys.__excepthook__ and sys.__displayhook__.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libsys.tex | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/Doc/lib/libsys.tex b/Doc/lib/libsys.tex index df32182..44b7853 100644 --- a/Doc/lib/libsys.tex +++ b/Doc/lib/libsys.tex @@ -48,11 +48,32 @@ Availability: Windows. If \var{value} is not \code{None}, this function prints it to \code{sys.stdout}, and saves it in \code{__builtin__._}. -This function is called when an expression is entered at the prompt -of an interactive Python session. It exists mainly so it can be -overridden. +\code{sys.displayhook} is called on the result of evaluating +an expression entered in an interactive Python session. +The display of these values can be customized by assigning +another function to \code{sys.displayhook}. \end{funcdesc} +\begin{funcdesc}{excepthook}{\var{type}, \var{value}, \var{traceback}} +This function prints out a given traceback and exception to +\code{sys.stderr}. + +\code{sys.excepthook} is called when an exception is raised +and uncaught. In an interactive session this happens just before +control is returned to the prompt; in a Python program this happens +just before the program exits. +The handling of such top-level exceptions can be customized by +assigning another function to \code{sys.excepthook}. +\end{funcdesc} + +\begin{datadesc}{__displayhook__} +\dataline{__excepthook__} +These objects contain the original values of \code{displayhook} +and \code{excepthook} at the start of the program. They are saved +so that \code{displayhook} and \code{excepthook} can be restored +in case they happen to get replaced with broken objects. +\end{datadesc} + \begin{funcdesc}{exc_info}{} This function returns a tuple of three values that give information about the exception that is currently being handled. The information |