rest25/library/cgitb.rst => rest262/library/cgitb.rst
21traceback information in HTML for CGI scripts.  It was later generalized to also
22display this information in plain text.)  After this module is activated, if an
23uncaught exception occurs, a detailed, formatted report will be displayed.  The
24report includes a traceback showing excerpts of the source code for each level,
25as well as the values of the arguments and local variables to currently running
26functions, to help you debug the problem.  Optionally, you can save this
27information to a file instead of sending it to the browser.
28
n29-To enable this feature, simply add one line to the top of your CGI script::
n29+To enable this feature, simply add this to the top of your CGI script::
30
n31-   import cgitb; cgitb.enable()
n31+   import cgitb
32+   cgitb.enable()
32
33The options to the :func:`enable` function control whether the report is
34displayed in the browser and whether the report is logged to a file for later
35analysis.
36
37
38.. function:: enable([display[, logdir[, context[, format]]]])
39
40   .. index:: single: excepthook() (in module sys)
41
42   This function causes the :mod:`cgitb` module to take over the interpreter's
n43-   default handling for exceptions by setting the value of ``sys.excepthook``.
n44+   default handling for exceptions by setting the value of :attr:`sys.excepthook`.
44
45   The optional argument *display* defaults to ``1`` and can be set to ``0`` to
46   suppress sending the traceback to the browser. If the argument *logdir* is
47   present, the traceback reports are written to files.  The value of *logdir*
48   should be a directory where these files will be placed. The optional argument
49   *context* is the number of lines of context to display around the current line
50   of source code in the traceback; this defaults to ``5``. If the optional
51   argument *format* is ``"html"``, the output is formatted as HTML.  Any other
54
55.. function:: handler([info])
56
57   This function handles an exception using the default settings (that is, show a
58   report in the browser, but don't log to a file). This can be used when you've
59   caught an exception and want to report it using :mod:`cgitb`.  The optional
60   *info* argument should be a 3-tuple containing an exception type, exception
61   value, and traceback object, exactly like the tuple returned by
t62-   ``sys.exc_info()``.  If the *info* argument is not supplied, the current
t63+   :func:`sys.exc_info`.  If the *info* argument is not supplied, the current
63-   exception is obtained from ``sys.exc_info()``.
64+   exception is obtained from :func:`sys.exc_info`.
64
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op