2024-05-08 16:34:40 -03:00
|
|
|
:mod:`!traceback` --- Print or retrieve a stack traceback
|
|
|
|
=========================================================
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
.. module:: traceback
|
|
|
|
:synopsis: Print or retrieve a stack traceback.
|
|
|
|
|
2016-06-11 16:02:54 -03:00
|
|
|
**Source code:** :source:`Lib/traceback.py`
|
|
|
|
|
|
|
|
--------------
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2024-10-10 07:21:12 -03:00
|
|
|
This module provides a standard interface to extract, format and print
|
|
|
|
stack traces of Python programs. It is more flexible than the
|
|
|
|
interpreter's default traceback display, and therefore makes it
|
|
|
|
possible to configure certain aspects of the output. Finally,
|
|
|
|
it contains a utility for capturing enough information about an
|
|
|
|
exception to print it later, without the need to save a reference
|
|
|
|
to the actual exception. Since exceptions can be the roots of large
|
|
|
|
objects graph, this utility can significantly improve
|
|
|
|
memory management.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-05-04 07:04:41 -03:00
|
|
|
.. index:: pair: object; traceback
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-12-09 18:43:53 -04:00
|
|
|
The module uses :ref:`traceback objects <traceback-objects>` --- these are
|
|
|
|
objects of type :class:`types.TracebackType`,
|
2023-12-14 10:10:35 -04:00
|
|
|
which are assigned to the :attr:`~BaseException.__traceback__` field of
|
|
|
|
:class:`BaseException` instances.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-02-03 23:49:29 -04:00
|
|
|
.. seealso::
|
|
|
|
|
|
|
|
Module :mod:`faulthandler`
|
|
|
|
Used to dump Python tracebacks explicitly, on a fault, after a timeout, or on a user signal.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-02-03 23:49:29 -04:00
|
|
|
Module :mod:`pdb`
|
|
|
|
Interactive source code debugger for Python programs.
|
|
|
|
|
2024-10-10 07:21:12 -03:00
|
|
|
The module's API can be divided into two parts:
|
|
|
|
|
|
|
|
* Module-level functions offering basic functionality, which are useful for interactive
|
|
|
|
inspection of exceptions and tracebacks.
|
|
|
|
|
|
|
|
* :class:`TracebackException` class and its helper classes
|
|
|
|
:class:`StackSummary` and :class:`FrameSummary`. These offer both more
|
|
|
|
flexibility in the output generated and the ability to store the information
|
|
|
|
necessary for later formatting without holding references to actual exception
|
|
|
|
and traceback objects.
|
|
|
|
|
|
|
|
|
|
|
|
Module-Level Functions
|
|
|
|
----------------------
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2016-01-16 01:45:17 -04:00
|
|
|
.. function:: print_tb(tb, limit=None, file=None)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
Print up to *limit* stack trace entries from
|
|
|
|
:ref:`traceback object <traceback-objects>` *tb* (starting
|
2016-01-16 01:45:17 -04:00
|
|
|
from the caller's frame) if *limit* is positive. Otherwise, print the last
|
|
|
|
``abs(limit)`` entries. If *limit* is omitted or ``None``, all entries are
|
|
|
|
printed. If *file* is omitted or ``None``, the output goes to
|
2023-12-14 10:10:35 -04:00
|
|
|
:data:`sys.stderr`; otherwise it should be an open
|
|
|
|
:term:`file <file object>` or :term:`file-like object` to
|
2016-01-16 01:45:17 -04:00
|
|
|
receive the output.
|
2015-05-03 07:19:46 -03:00
|
|
|
|
2024-08-25 19:50:43 -03:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
The meaning of the *limit* parameter is different than the meaning
|
|
|
|
of :const:`sys.tracebacklimit`. A negative *limit* value corresponds to
|
|
|
|
a positive value of :const:`!sys.tracebacklimit`, whereas the behaviour of
|
|
|
|
a positive *limit* value cannot be achieved with
|
|
|
|
:const:`!sys.tracebacklimit`.
|
|
|
|
|
2015-05-03 07:19:46 -03:00
|
|
|
.. versionchanged:: 3.5
|
|
|
|
Added negative *limit* support.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2020-11-05 18:18:44 -04:00
|
|
|
.. function:: print_exception(exc, /[, value, tb], limit=None, \
|
|
|
|
file=None, chain=True)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
Print exception information and stack trace entries from
|
|
|
|
:ref:`traceback object <traceback-objects>`
|
2016-01-16 01:45:17 -04:00
|
|
|
*tb* to *file*. This differs from :func:`print_tb` in the following
|
2008-07-19 12:51:07 -03:00
|
|
|
ways:
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2016-01-16 01:45:17 -04:00
|
|
|
* if *tb* is not ``None``, it prints a header ``Traceback (most recent
|
2008-07-19 12:51:07 -03:00
|
|
|
call last):``
|
2018-10-26 03:00:49 -03:00
|
|
|
|
2020-11-05 18:18:44 -04:00
|
|
|
* it prints the exception type and *value* after the stack trace
|
2018-10-26 03:00:49 -03:00
|
|
|
|
2018-10-28 08:41:26 -03:00
|
|
|
.. index:: single: ^ (caret); marker
|
2018-10-26 03:00:49 -03:00
|
|
|
|
2017-06-01 18:54:01 -03:00
|
|
|
* if *type(value)* is :exc:`SyntaxError` and *value* has the appropriate
|
|
|
|
format, it prints the line where the syntax error occurred with a caret
|
|
|
|
indicating the approximate position of the error.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2020-11-05 18:18:44 -04:00
|
|
|
Since Python 3.10, instead of passing *value* and *tb*, an exception object
|
|
|
|
can be passed as the first argument. If *value* and *tb* are provided, the
|
|
|
|
first argument is ignored in order to provide backwards compatibility.
|
|
|
|
|
2015-05-03 07:19:46 -03:00
|
|
|
The optional *limit* argument has the same meaning as for :func:`print_tb`.
|
2008-07-19 12:51:07 -03:00
|
|
|
If *chain* is true (the default), then chained exceptions (the
|
2023-12-13 14:59:36 -04:00
|
|
|
:attr:`~BaseException.__cause__` or :attr:`~BaseException.__context__`
|
|
|
|
attributes of the exception) will be
|
2008-07-19 12:51:07 -03:00
|
|
|
printed as well, like the interpreter itself does when printing an unhandled
|
|
|
|
exception.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2017-06-01 18:54:01 -03:00
|
|
|
.. versionchanged:: 3.5
|
|
|
|
The *etype* argument is ignored and inferred from the type of *value*.
|
|
|
|
|
2020-11-05 18:18:44 -04:00
|
|
|
.. versionchanged:: 3.10
|
|
|
|
The *etype* parameter has been renamed to *exc* and is now
|
|
|
|
positional-only.
|
|
|
|
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2009-09-16 12:58:14 -03:00
|
|
|
.. function:: print_exc(limit=None, file=None, chain=True)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-02-20 17:54:19 -04:00
|
|
|
This is a shorthand for ``print_exception(sys.exception(), limit, file,
|
2015-05-03 07:19:46 -03:00
|
|
|
chain)``.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2009-09-16 12:58:14 -03:00
|
|
|
.. function:: print_last(limit=None, file=None, chain=True)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-06-02 13:01:46 -03:00
|
|
|
This is a shorthand for ``print_exception(sys.last_exc, limit, file,
|
|
|
|
chain)``. In general it will work only after an exception has reached
|
|
|
|
an interactive prompt (see :data:`sys.last_exc`).
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2009-09-16 12:58:14 -03:00
|
|
|
.. function:: print_stack(f=None, limit=None, file=None)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2015-05-03 07:19:46 -03:00
|
|
|
Print up to *limit* stack trace entries (starting from the invocation
|
|
|
|
point) if *limit* is positive. Otherwise, print the last ``abs(limit)``
|
|
|
|
entries. If *limit* is omitted or ``None``, all entries are printed.
|
2023-12-14 10:10:35 -04:00
|
|
|
The optional *f* argument can be used to specify an alternate
|
|
|
|
:ref:`stack frame <frame-objects>`
|
2015-05-03 07:19:46 -03:00
|
|
|
to start. The optional *file* argument has the same meaning as for
|
|
|
|
:func:`print_tb`.
|
|
|
|
|
|
|
|
.. versionchanged:: 3.5
|
|
|
|
Added negative *limit* support.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2016-01-16 01:45:17 -04:00
|
|
|
.. function:: extract_tb(tb, limit=None)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2018-08-02 13:08:59 -03:00
|
|
|
Return a :class:`StackSummary` object representing a list of "pre-processed"
|
2023-12-14 10:10:35 -04:00
|
|
|
stack trace entries extracted from the
|
|
|
|
:ref:`traceback object <traceback-objects>` *tb*. It is useful
|
2018-08-02 13:08:59 -03:00
|
|
|
for alternate formatting of stack traces. The optional *limit* argument has
|
|
|
|
the same meaning as for :func:`print_tb`. A "pre-processed" stack trace
|
|
|
|
entry is a :class:`FrameSummary` object containing attributes
|
|
|
|
:attr:`~FrameSummary.filename`, :attr:`~FrameSummary.lineno`,
|
|
|
|
:attr:`~FrameSummary.name`, and :attr:`~FrameSummary.line` representing the
|
2023-12-14 10:10:35 -04:00
|
|
|
information that is usually printed for a stack trace.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2009-09-16 12:58:14 -03:00
|
|
|
.. function:: extract_stack(f=None, limit=None)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
Extract the raw traceback from the current
|
|
|
|
:ref:`stack frame <frame-objects>`. The return value has
|
2007-08-15 11:28:22 -03:00
|
|
|
the same format as for :func:`extract_tb`. The optional *f* and *limit*
|
|
|
|
arguments have the same meaning as for :func:`print_stack`.
|
|
|
|
|
|
|
|
|
2016-01-16 01:45:17 -04:00
|
|
|
.. function:: format_list(extracted_list)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2018-08-02 13:08:59 -03:00
|
|
|
Given a list of tuples or :class:`FrameSummary` objects as returned by
|
|
|
|
:func:`extract_tb` or :func:`extract_stack`, return a list of strings ready
|
|
|
|
for printing. Each string in the resulting list corresponds to the item with
|
|
|
|
the same index in the argument list. Each string ends in a newline; the
|
|
|
|
strings may contain internal newlines as well, for those items whose source
|
|
|
|
text line is not ``None``.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2023-10-27 07:11:26 -03:00
|
|
|
.. function:: format_exception_only(exc, /[, value], *, show_group=False)
|
2020-11-05 18:18:44 -04:00
|
|
|
|
|
|
|
Format the exception part of a traceback using an exception value such as
|
2023-12-14 10:10:35 -04:00
|
|
|
given by :data:`sys.last_value`. The return value is a list of strings, each
|
2023-09-12 11:54:04 -03:00
|
|
|
ending in a newline. The list contains the exception's message, which is
|
|
|
|
normally a single string; however, for :exc:`SyntaxError` exceptions, it
|
|
|
|
contains several lines that (when printed) display detailed information
|
|
|
|
about where the syntax error occurred. Following the message, the list
|
|
|
|
contains the exception's :attr:`notes <BaseException.__notes__>`.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2020-11-05 18:18:44 -04:00
|
|
|
Since Python 3.10, instead of passing *value*, an exception object
|
|
|
|
can be passed as the first argument. If *value* is provided, the first
|
|
|
|
argument is ignored in order to provide backwards compatibility.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-10-27 07:11:26 -03:00
|
|
|
When *show_group* is ``True``, and the exception is an instance of
|
|
|
|
:exc:`BaseExceptionGroup`, the nested exceptions are included as
|
|
|
|
well, recursively, with indentation relative to their nesting depth.
|
|
|
|
|
2020-11-05 18:18:44 -04:00
|
|
|
.. versionchanged:: 3.10
|
|
|
|
The *etype* parameter has been renamed to *exc* and is now
|
|
|
|
positional-only.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-09-12 11:54:04 -03:00
|
|
|
.. versionchanged:: 3.11
|
2023-12-14 10:10:35 -04:00
|
|
|
The returned list now includes any
|
|
|
|
:attr:`notes <BaseException.__notes__>` attached to the exception.
|
2023-09-12 11:54:04 -03:00
|
|
|
|
2023-10-27 07:11:26 -03:00
|
|
|
.. versionchanged:: 3.13
|
|
|
|
*show_group* parameter was added.
|
|
|
|
|
2020-11-05 18:18:44 -04:00
|
|
|
|
|
|
|
.. function:: format_exception(exc, /[, value, tb], limit=None, chain=True)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
Format a stack trace and the exception information. The arguments have the
|
|
|
|
same meaning as the corresponding arguments to :func:`print_exception`. The
|
2016-01-16 01:45:17 -04:00
|
|
|
return value is a list of strings, each ending in a newline and some
|
|
|
|
containing internal newlines. When these lines are concatenated and printed,
|
|
|
|
exactly the same text is printed as does :func:`print_exception`.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2017-06-01 18:54:01 -03:00
|
|
|
.. versionchanged:: 3.5
|
|
|
|
The *etype* argument is ignored and inferred from the type of *value*.
|
|
|
|
|
2020-11-05 18:18:44 -04:00
|
|
|
.. versionchanged:: 3.10
|
|
|
|
This function's behavior and signature were modified to match
|
|
|
|
:func:`print_exception`.
|
|
|
|
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2009-09-16 12:58:14 -03:00
|
|
|
.. function:: format_exc(limit=None, chain=True)
|
2008-07-19 12:51:07 -03:00
|
|
|
|
2016-01-16 01:45:17 -04:00
|
|
|
This is like ``print_exc(limit)`` but returns a string instead of printing to
|
|
|
|
a file.
|
2008-07-19 12:51:07 -03:00
|
|
|
|
|
|
|
|
2009-09-16 12:58:14 -03:00
|
|
|
.. function:: format_tb(tb, limit=None)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
A shorthand for ``format_list(extract_tb(tb, limit))``.
|
|
|
|
|
|
|
|
|
2009-09-16 12:58:14 -03:00
|
|
|
.. function:: format_stack(f=None, limit=None)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
A shorthand for ``format_list(extract_stack(f, limit))``.
|
|
|
|
|
2013-09-15 19:15:56 -03:00
|
|
|
.. function:: clear_frames(tb)
|
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
Clears the local variables of all the stack frames in a
|
|
|
|
:ref:`traceback <traceback-objects>` *tb*
|
|
|
|
by calling the :meth:`~frame.clear` method of each
|
|
|
|
:ref:`frame object <frame-objects>`.
|
2013-09-15 19:15:56 -03:00
|
|
|
|
|
|
|
.. versionadded:: 3.4
|
|
|
|
|
2015-03-04 19:07:57 -04:00
|
|
|
.. function:: walk_stack(f)
|
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
Walk a stack following :attr:`f.f_back <frame.f_back>` from the given frame,
|
|
|
|
yielding the frame
|
2015-03-06 06:18:06 -04:00
|
|
|
and line number for each frame. If *f* is ``None``, the current stack is
|
|
|
|
used. This helper is used with :meth:`StackSummary.extract`.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
|
|
|
.. versionadded:: 3.5
|
|
|
|
|
|
|
|
.. function:: walk_tb(tb)
|
|
|
|
|
2023-12-09 18:43:53 -04:00
|
|
|
Walk a traceback following :attr:`~traceback.tb_next` yielding the frame and
|
|
|
|
line number
|
2015-03-06 06:18:06 -04:00
|
|
|
for each frame. This helper is used with :meth:`StackSummary.extract`.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
|
|
|
.. versionadded:: 3.5
|
|
|
|
|
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
:class:`!TracebackException` Objects
|
|
|
|
------------------------------------
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. versionadded:: 3.5
|
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
:class:`!TracebackException` objects are created from actual exceptions to
|
2024-10-10 07:21:12 -03:00
|
|
|
capture data for later printing. They offer a more lightweight method of
|
|
|
|
storing this information by avoiding holding references to
|
|
|
|
:ref:`traceback<traceback-objects>` and :ref:`frame<frame-objects>` objects
|
|
|
|
In addition, they expose more options to configure the output compared to
|
|
|
|
the module-level functions described above.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-05-29 15:28:37 -03:00
|
|
|
.. class:: TracebackException(exc_type, exc_value, exc_traceback, *, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10)
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2024-10-10 07:21:12 -03:00
|
|
|
Capture an exception for later rendering. The meaning of *limit*,
|
|
|
|
*lookup_lines* and *capture_locals* are as for the :class:`StackSummary`
|
|
|
|
class.
|
2015-03-05 03:28:52 -04:00
|
|
|
|
2023-12-13 14:59:36 -04:00
|
|
|
If *compact* is true, only data that is required by
|
|
|
|
:class:`!TracebackException`'s :meth:`format` method
|
|
|
|
is saved in the class attributes. In particular, the
|
|
|
|
:attr:`__context__` field is calculated only if :attr:`__cause__` is
|
|
|
|
``None`` and :attr:`__suppress_context__` is false.
|
2021-01-14 22:45:02 -04:00
|
|
|
|
2015-03-05 03:28:52 -04:00
|
|
|
Note that when locals are captured, they are also shown in the traceback.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-05-29 15:28:37 -03:00
|
|
|
*max_group_width* and *max_group_depth* control the formatting of exception
|
|
|
|
groups (see :exc:`BaseExceptionGroup`). The depth refers to the nesting
|
|
|
|
level of the group, and the width refers to the size of a single exception
|
|
|
|
group's exceptions array. The formatted output is truncated when either
|
|
|
|
limit is exceeded.
|
|
|
|
|
2023-09-12 11:54:04 -03:00
|
|
|
.. versionchanged:: 3.10
|
|
|
|
Added the *compact* parameter.
|
|
|
|
|
|
|
|
.. versionchanged:: 3.11
|
|
|
|
Added the *max_group_width* and *max_group_depth* parameters.
|
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: __cause__
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-12-13 14:59:36 -04:00
|
|
|
A :class:`!TracebackException` of the original
|
|
|
|
:attr:`~BaseException.__cause__`.
|
2015-03-05 03:28:52 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: __context__
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-12-13 14:59:36 -04:00
|
|
|
A :class:`!TracebackException` of the original
|
|
|
|
:attr:`~BaseException.__context__`.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-05-29 15:28:37 -03:00
|
|
|
.. attribute:: exceptions
|
|
|
|
|
|
|
|
If ``self`` represents an :exc:`ExceptionGroup`, this field holds a list of
|
2023-12-13 14:59:36 -04:00
|
|
|
:class:`!TracebackException` instances representing the nested exceptions.
|
2023-05-29 15:28:37 -03:00
|
|
|
Otherwise it is ``None``.
|
|
|
|
|
|
|
|
.. versionadded:: 3.11
|
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: __suppress_context__
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-12-13 14:59:36 -04:00
|
|
|
The :attr:`~BaseException.__suppress_context__` value from the original
|
|
|
|
exception.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2022-04-20 09:43:10 -03:00
|
|
|
.. attribute:: __notes__
|
|
|
|
|
2023-12-13 14:59:36 -04:00
|
|
|
The :attr:`~BaseException.__notes__` value from the original exception,
|
|
|
|
or ``None``
|
2022-04-20 09:43:10 -03:00
|
|
|
if the exception does not have any notes. If it is not ``None``
|
|
|
|
is it formatted in the traceback after the exception string.
|
|
|
|
|
|
|
|
.. versionadded:: 3.11
|
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: stack
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
A :class:`StackSummary` representing the traceback.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: exc_type
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
The class of the original traceback.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-11-28 04:03:25 -04:00
|
|
|
.. deprecated:: 3.13
|
|
|
|
|
|
|
|
.. attribute:: exc_type_str
|
|
|
|
|
|
|
|
String display of the class of the original exception.
|
|
|
|
|
|
|
|
.. versionadded:: 3.13
|
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: filename
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
For syntax errors - the file name where the error occurred.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: lineno
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
For syntax errors - the line number where the error occurred.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-06-05 13:10:13 -03:00
|
|
|
.. attribute:: end_lineno
|
|
|
|
|
|
|
|
For syntax errors - the end line number where the error occurred.
|
|
|
|
Can be ``None`` if not present.
|
|
|
|
|
|
|
|
.. versionadded:: 3.10
|
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: text
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
For syntax errors - the text where the error occurred.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: offset
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
For syntax errors - the offset into the text where the error occurred.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-06-05 13:10:13 -03:00
|
|
|
.. attribute:: end_offset
|
|
|
|
|
|
|
|
For syntax errors - the end offset into the text where the error occurred.
|
|
|
|
Can be ``None`` if not present.
|
|
|
|
|
|
|
|
.. versionadded:: 3.10
|
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. attribute:: msg
|
|
|
|
|
|
|
|
For syntax errors - the compiler error message.
|
|
|
|
|
|
|
|
.. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False)
|
|
|
|
|
|
|
|
Capture an exception for later rendering. *limit*, *lookup_lines* and
|
|
|
|
*capture_locals* are as for the :class:`StackSummary` class.
|
|
|
|
|
|
|
|
Note that when locals are captured, they are also shown in the traceback.
|
|
|
|
|
2021-05-22 13:39:33 -03:00
|
|
|
.. method:: print(*, file=None, chain=True)
|
|
|
|
|
|
|
|
Print to *file* (default ``sys.stderr``) the exception information returned by
|
|
|
|
:meth:`format`.
|
|
|
|
|
|
|
|
.. versionadded:: 3.11
|
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. method:: format(*, chain=True)
|
|
|
|
|
|
|
|
Format the exception.
|
|
|
|
|
2023-12-13 14:59:36 -04:00
|
|
|
If *chain* is not ``True``, :attr:`__cause__` and :attr:`__context__`
|
|
|
|
will not be formatted.
|
2015-03-06 06:18:06 -04:00
|
|
|
|
|
|
|
The return value is a generator of strings, each ending in a newline and
|
|
|
|
some containing internal newlines. :func:`~traceback.print_exception`
|
|
|
|
is a wrapper around this method which just prints the lines to a file.
|
|
|
|
|
2023-06-06 06:26:18 -03:00
|
|
|
.. method:: format_exception_only(*, show_group=False)
|
2015-03-06 06:18:06 -04:00
|
|
|
|
|
|
|
Format the exception part of the traceback.
|
|
|
|
|
|
|
|
The return value is a generator of strings, each ending in a newline.
|
|
|
|
|
2023-09-12 11:54:04 -03:00
|
|
|
When *show_group* is ``False``, the generator emits the exception's
|
|
|
|
message followed by its notes (if it has any). The exception message
|
|
|
|
is normally a single string; however, for :exc:`SyntaxError` exceptions,
|
|
|
|
it consists of several lines that (when printed) display detailed
|
|
|
|
information about where the syntax error occurred.
|
2015-03-06 06:18:06 -04:00
|
|
|
|
2023-06-06 06:26:18 -03:00
|
|
|
When *show_group* is ``True``, and the exception is an instance of
|
|
|
|
:exc:`BaseExceptionGroup`, the nested exceptions are included as
|
|
|
|
well, recursively, with indentation relative to their nesting depth.
|
|
|
|
|
2023-09-12 11:54:04 -03:00
|
|
|
.. versionchanged:: 3.11
|
2023-12-14 10:10:35 -04:00
|
|
|
The exception's :attr:`notes <BaseException.__notes__>` are now
|
|
|
|
included in the output.
|
2023-09-12 11:54:04 -03:00
|
|
|
|
2023-06-06 06:26:18 -03:00
|
|
|
.. versionchanged:: 3.13
|
|
|
|
Added the *show_group* parameter.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-06-06 06:26:18 -03:00
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
:class:`!StackSummary` Objects
|
|
|
|
------------------------------
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. versionadded:: 3.5
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
:class:`!StackSummary` objects represent a call stack ready for formatting.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. class:: StackSummary
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. classmethod:: extract(frame_gen, *, limit=None, lookup_lines=True, capture_locals=False)
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
Construct a :class:`!StackSummary` object from a frame generator (such as
|
2015-03-06 06:18:06 -04:00
|
|
|
is returned by :func:`~traceback.walk_stack` or
|
|
|
|
:func:`~traceback.walk_tb`).
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
If *limit* is supplied, only this many frames are taken from *frame_gen*.
|
|
|
|
If *lookup_lines* is ``False``, the returned :class:`FrameSummary`
|
|
|
|
objects will not have read their lines in yet, making the cost of
|
2023-12-14 10:10:35 -04:00
|
|
|
creating the :class:`!StackSummary` cheaper (which may be valuable if it
|
2015-03-06 06:18:06 -04:00
|
|
|
may not actually get formatted). If *capture_locals* is ``True`` the
|
2023-12-14 10:10:35 -04:00
|
|
|
local variables in each :class:`!FrameSummary` are captured as object
|
2015-03-06 06:18:06 -04:00
|
|
|
representations.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2022-07-11 06:14:15 -03:00
|
|
|
.. versionchanged:: 3.12
|
|
|
|
Exceptions raised from :func:`repr` on a local variable (when
|
|
|
|
*capture_locals* is ``True``) are no longer propagated to the caller.
|
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. classmethod:: from_list(a_list)
|
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
Construct a :class:`!StackSummary` object from a supplied list of
|
2018-08-02 13:08:59 -03:00
|
|
|
:class:`FrameSummary` objects or old-style list of tuples. Each tuple
|
2023-12-14 10:10:35 -04:00
|
|
|
should be a 4-tuple with *filename*, *lineno*, *name*, *line* as the
|
|
|
|
elements.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2016-08-15 00:11:34 -03:00
|
|
|
.. method:: format()
|
|
|
|
|
|
|
|
Returns a list of strings ready for printing. Each string in the
|
2023-12-14 10:10:35 -04:00
|
|
|
resulting list corresponds to a single :ref:`frame <frame-objects>` from
|
|
|
|
the stack.
|
2016-08-15 00:11:34 -03:00
|
|
|
Each string ends in a newline; the strings may contain internal
|
|
|
|
newlines as well, for those items with source text lines.
|
|
|
|
|
|
|
|
For long sequences of the same frame and line, the first few
|
|
|
|
repetitions are shown, followed by a summary line stating the exact
|
|
|
|
number of further repetitions.
|
|
|
|
|
2016-08-15 21:58:14 -03:00
|
|
|
.. versionchanged:: 3.6
|
|
|
|
Long sequences of repeated frames are now abbreviated.
|
2016-08-15 00:11:34 -03:00
|
|
|
|
2021-09-03 18:39:23 -03:00
|
|
|
.. method:: format_frame_summary(frame_summary)
|
2021-07-16 09:21:16 -03:00
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
Returns a string for printing one of the :ref:`frames <frame-objects>`
|
|
|
|
involved in the stack.
|
2021-09-03 18:39:23 -03:00
|
|
|
This method is called for each :class:`FrameSummary` object to be
|
|
|
|
printed by :meth:`StackSummary.format`. If it returns ``None``, the
|
|
|
|
frame is omitted from the output.
|
2021-07-16 09:21:16 -03:00
|
|
|
|
|
|
|
.. versionadded:: 3.11
|
|
|
|
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
:class:`!FrameSummary` Objects
|
|
|
|
------------------------------
|
2015-03-04 19:07:57 -04:00
|
|
|
|
2015-03-06 06:18:06 -04:00
|
|
|
.. versionadded:: 3.5
|
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
A :class:`!FrameSummary` object represents a single :ref:`frame <frame-objects>`
|
|
|
|
in a :ref:`traceback <traceback-objects>`.
|
2015-03-04 19:07:57 -04:00
|
|
|
|
|
|
|
.. class:: FrameSummary(filename, lineno, name, lookup_line=True, locals=None, line=None)
|
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
Represents a single :ref:`frame <frame-objects>` in the
|
|
|
|
:ref:`traceback <traceback-objects>` or stack that is being formatted
|
|
|
|
or printed. It may optionally have a stringified version of the frame's
|
2015-03-06 06:18:06 -04:00
|
|
|
locals included in it. If *lookup_line* is ``False``, the source code is not
|
2023-12-14 10:10:35 -04:00
|
|
|
looked up until the :class:`!FrameSummary` has the :attr:`~FrameSummary.line`
|
|
|
|
attribute accessed (which also happens when casting it to a :class:`tuple`).
|
2015-03-06 06:18:06 -04:00
|
|
|
:attr:`~FrameSummary.line` may be directly provided, and will prevent line
|
|
|
|
lookups happening at all. *locals* is an optional local variable
|
2024-05-21 00:32:15 -03:00
|
|
|
mapping, and if supplied the variable representations are stored in the
|
2015-03-06 06:18:06 -04:00
|
|
|
summary for later display.
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2023-12-14 10:10:35 -04:00
|
|
|
:class:`!FrameSummary` instances have the following attributes:
|
|
|
|
|
|
|
|
.. attribute:: FrameSummary.filename
|
|
|
|
|
|
|
|
The filename of the source code for this frame. Equivalent to accessing
|
|
|
|
:attr:`f.f_code.co_filename <codeobject.co_filename>` on a
|
|
|
|
:ref:`frame object <frame-objects>` *f*.
|
|
|
|
|
|
|
|
.. attribute:: FrameSummary.lineno
|
|
|
|
|
|
|
|
The line number of the source code for this frame.
|
|
|
|
|
|
|
|
.. attribute:: FrameSummary.name
|
|
|
|
|
|
|
|
Equivalent to accessing :attr:`f.f_code.co_name <codeobject.co_name>` on
|
|
|
|
a :ref:`frame object <frame-objects>` *f*.
|
|
|
|
|
|
|
|
.. attribute:: FrameSummary.line
|
|
|
|
|
|
|
|
A string representing the source code for this frame, with leading and
|
|
|
|
trailing whitespace stripped.
|
|
|
|
If the source is not available, it is ``None``.
|
|
|
|
|
2007-08-15 11:28:22 -03:00
|
|
|
.. _traceback-example:
|
|
|
|
|
2024-10-10 07:21:12 -03:00
|
|
|
Examples of Using the Module-Level Functions
|
|
|
|
--------------------------------------------
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
This simple example implements a basic read-eval-print loop, similar to (but
|
|
|
|
less useful than) the standard Python interactive interpreter loop. For a more
|
|
|
|
complete implementation of the interpreter loop, refer to the :mod:`code`
|
|
|
|
module. ::
|
|
|
|
|
|
|
|
import sys, traceback
|
|
|
|
|
|
|
|
def run_user_code(envdir):
|
2007-12-02 18:48:17 -04:00
|
|
|
source = input(">>> ")
|
2007-08-15 11:28:22 -03:00
|
|
|
try:
|
|
|
|
exec(source, envdir)
|
2012-11-02 17:07:26 -03:00
|
|
|
except Exception:
|
2007-09-01 20:34:30 -03:00
|
|
|
print("Exception in user code:")
|
|
|
|
print("-"*60)
|
2007-08-15 11:28:22 -03:00
|
|
|
traceback.print_exc(file=sys.stdout)
|
2007-09-01 20:34:30 -03:00
|
|
|
print("-"*60)
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
envdir = {}
|
2007-09-01 20:34:30 -03:00
|
|
|
while True:
|
2007-08-15 11:28:22 -03:00
|
|
|
run_user_code(envdir)
|
|
|
|
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
|
|
|
|
The following example demonstrates the different ways to print and format the
|
2009-04-27 15:38:19 -03:00
|
|
|
exception and traceback:
|
|
|
|
|
|
|
|
.. testcode::
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
|
|
|
|
import sys, traceback
|
|
|
|
|
|
|
|
def lumberjack():
|
2022-09-05 18:30:51 -03:00
|
|
|
bright_side_of_life()
|
2009-01-03 17:18:54 -04:00
|
|
|
|
2022-09-05 18:30:51 -03:00
|
|
|
def bright_side_of_life():
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
return tuple()[0]
|
2009-01-03 17:18:54 -04:00
|
|
|
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
try:
|
|
|
|
lumberjack()
|
2024-10-10 07:21:12 -03:00
|
|
|
except IndexError as exc:
|
2008-02-01 07:56:49 -04:00
|
|
|
print("*** print_tb:")
|
2023-02-20 17:54:19 -04:00
|
|
|
traceback.print_tb(exc.__traceback__, limit=1, file=sys.stdout)
|
2008-02-01 07:56:49 -04:00
|
|
|
print("*** print_exception:")
|
2023-02-20 17:54:19 -04:00
|
|
|
traceback.print_exception(exc, limit=2, file=sys.stdout)
|
2008-02-01 07:56:49 -04:00
|
|
|
print("*** print_exc:")
|
2016-08-10 02:35:27 -03:00
|
|
|
traceback.print_exc(limit=2, file=sys.stdout)
|
2008-02-01 07:56:49 -04:00
|
|
|
print("*** format_exc, first and last line:")
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
formatted_lines = traceback.format_exc().splitlines()
|
2008-02-01 07:56:49 -04:00
|
|
|
print(formatted_lines[0])
|
|
|
|
print(formatted_lines[-1])
|
|
|
|
print("*** format_exception:")
|
2023-02-20 17:54:19 -04:00
|
|
|
print(repr(traceback.format_exception(exc)))
|
2008-02-01 07:56:49 -04:00
|
|
|
print("*** extract_tb:")
|
2023-02-20 17:54:19 -04:00
|
|
|
print(repr(traceback.extract_tb(exc.__traceback__)))
|
2008-02-01 07:56:49 -04:00
|
|
|
print("*** format_tb:")
|
2023-02-20 17:54:19 -04:00
|
|
|
print(repr(traceback.format_tb(exc.__traceback__)))
|
|
|
|
print("*** tb_lineno:", exc.__traceback__.tb_lineno)
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
|
2009-04-27 15:38:19 -03:00
|
|
|
The output for the example would look similar to this:
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
|
2009-04-27 15:38:19 -03:00
|
|
|
.. testoutput::
|
|
|
|
:options: +NORMALIZE_WHITESPACE
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
|
|
|
|
*** print_tb:
|
2009-04-27 15:38:19 -03:00
|
|
|
File "<doctest...>", line 10, in <module>
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
lumberjack()
|
2023-12-01 18:18:16 -04:00
|
|
|
~~~~~~~~~~^^
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
*** print_exception:
|
|
|
|
Traceback (most recent call last):
|
2009-04-27 15:38:19 -03:00
|
|
|
File "<doctest...>", line 10, in <module>
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
lumberjack()
|
2023-12-01 18:18:16 -04:00
|
|
|
~~~~~~~~~~^^
|
2009-04-27 15:38:19 -03:00
|
|
|
File "<doctest...>", line 4, in lumberjack
|
2022-09-05 18:30:51 -03:00
|
|
|
bright_side_of_life()
|
2023-12-01 18:18:16 -04:00
|
|
|
~~~~~~~~~~~~~~~~~~~^^
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
IndexError: tuple index out of range
|
|
|
|
*** print_exc:
|
|
|
|
Traceback (most recent call last):
|
2009-04-27 15:38:19 -03:00
|
|
|
File "<doctest...>", line 10, in <module>
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
lumberjack()
|
2023-12-01 18:18:16 -04:00
|
|
|
~~~~~~~~~~^^
|
2009-04-27 15:38:19 -03:00
|
|
|
File "<doctest...>", line 4, in lumberjack
|
2022-09-05 18:30:51 -03:00
|
|
|
bright_side_of_life()
|
2023-12-01 18:18:16 -04:00
|
|
|
~~~~~~~~~~~~~~~~~~~^^
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
IndexError: tuple index out of range
|
|
|
|
*** format_exc, first and last line:
|
|
|
|
Traceback (most recent call last):
|
|
|
|
IndexError: tuple index out of range
|
|
|
|
*** format_exception:
|
|
|
|
['Traceback (most recent call last):\n',
|
2023-12-01 18:18:16 -04:00
|
|
|
' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ~~~~~~~~~~^^\n',
|
|
|
|
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_life()\n ~~~~~~~~~~~~~~~~~~~^^\n',
|
2022-09-05 18:30:51 -03:00
|
|
|
' File "<doctest default[0]>", line 7, in bright_side_of_life\n return tuple()[0]\n ~~~~~~~^^^\n',
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
'IndexError: tuple index out of range\n']
|
|
|
|
*** extract_tb:
|
2016-08-10 02:35:27 -03:00
|
|
|
[<FrameSummary file <doctest...>, line 10 in <module>>,
|
|
|
|
<FrameSummary file <doctest...>, line 4 in lumberjack>,
|
2022-09-05 18:30:51 -03:00
|
|
|
<FrameSummary file <doctest...>, line 7 in bright_side_of_life>]
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
*** format_tb:
|
2023-12-01 18:18:16 -04:00
|
|
|
[' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ~~~~~~~~~~^^\n',
|
|
|
|
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_life()\n ~~~~~~~~~~~~~~~~~~~^^\n',
|
2022-09-05 18:30:51 -03:00
|
|
|
' File "<doctest default[0]>", line 7, in bright_side_of_life\n return tuple()[0]\n ~~~~~~~^^^\n']
|
2009-04-27 15:38:19 -03:00
|
|
|
*** tb_lineno: 10
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
The following example shows the different ways to print and format the stack::
|
|
|
|
|
|
|
|
>>> import traceback
|
|
|
|
>>> def another_function():
|
|
|
|
... lumberstack()
|
2009-01-03 17:18:54 -04:00
|
|
|
...
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
>>> def lumberstack():
|
|
|
|
... traceback.print_stack()
|
2008-02-01 07:56:49 -04:00
|
|
|
... print(repr(traceback.extract_stack()))
|
|
|
|
... print(repr(traceback.format_stack()))
|
2009-01-03 17:18:54 -04:00
|
|
|
...
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
>>> another_function()
|
|
|
|
File "<doctest>", line 10, in <module>
|
|
|
|
another_function()
|
|
|
|
File "<doctest>", line 3, in another_function
|
|
|
|
lumberstack()
|
|
|
|
File "<doctest>", line 6, in lumberstack
|
|
|
|
traceback.print_stack()
|
|
|
|
[('<doctest>', 10, '<module>', 'another_function()'),
|
|
|
|
('<doctest>', 3, 'another_function', 'lumberstack()'),
|
2008-02-01 07:56:49 -04:00
|
|
|
('<doctest>', 7, 'lumberstack', 'print(repr(traceback.extract_stack()))')]
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
[' File "<doctest>", line 10, in <module>\n another_function()\n',
|
|
|
|
' File "<doctest>", line 3, in another_function\n lumberstack()\n',
|
2008-02-01 07:56:49 -04:00
|
|
|
' File "<doctest>", line 8, in lumberstack\n print(repr(traceback.format_stack()))\n']
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
|
|
|
|
|
2009-04-27 15:38:19 -03:00
|
|
|
This last example demonstrates the final few formatting functions:
|
|
|
|
|
|
|
|
.. doctest::
|
|
|
|
:options: +NORMALIZE_WHITESPACE
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
|
|
|
|
>>> import traceback
|
2009-04-27 13:22:44 -03:00
|
|
|
>>> traceback.format_list([('spam.py', 3, '<module>', 'spam.eggs()'),
|
|
|
|
... ('eggs.py', 42, 'eggs', 'return "bacon"')])
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
[' File "spam.py", line 3, in <module>\n spam.eggs()\n',
|
|
|
|
' File "eggs.py", line 42, in eggs\n return "bacon"\n']
|
2009-04-27 13:22:44 -03:00
|
|
|
>>> an_error = IndexError('tuple index out of range')
|
2024-10-10 07:21:12 -03:00
|
|
|
>>> traceback.format_exception_only(an_error)
|
Merged revisions 59333-59370 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix typo.
........
r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed quoting and paths in the sqlite project file
........
r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed error in regrtest. I must have missed the spot.
........
r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
........
r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line
Added msg to Misc/NEWS
........
r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line
Spelling fix
........
r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
........
r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line
Error checking was too aggressive (reported by Chris Tismer)
........
r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines
Add examples to re docs. Written for GHOP by Dan Finnie.
........
r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines
Fix markup.
........
r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line
Updated documentation and build_tkinter.py script
........
r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines
Another markup fix.
........
r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines
This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard
by purging bindings to OSA's debug API's. Those APIs we're completely
unsupported on OSX 10.4 and are no longer available on OSX 10.5.
Note that this patches a generated file. This is somewhat acceptable because
regenerating the file is non-trivial and wouldn't use system headers anyway.
........
r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line
Fixed bug #1557 by using popen.communicate() before popen.wait()
........
2007-12-05 16:18:38 -04:00
|
|
|
['IndexError: tuple index out of range\n']
|
2024-10-10 07:21:12 -03:00
|
|
|
|
|
|
|
|
|
|
|
Examples of Using :class:`TracebackException`
|
|
|
|
---------------------------------------------
|
|
|
|
|
|
|
|
With the helper class, we have more options::
|
|
|
|
|
|
|
|
>>> import sys
|
|
|
|
>>> from traceback import TracebackException
|
|
|
|
>>>
|
|
|
|
>>> def lumberjack():
|
|
|
|
... bright_side_of_life()
|
|
|
|
...
|
|
|
|
>>> def bright_side_of_life():
|
|
|
|
... t = "bright", "side", "of", "life"
|
|
|
|
... return t[5]
|
|
|
|
...
|
|
|
|
>>> try:
|
|
|
|
... lumberjack()
|
|
|
|
... except IndexError as e:
|
|
|
|
... exc = e
|
|
|
|
...
|
|
|
|
>>> try:
|
|
|
|
... try:
|
|
|
|
... lumberjack()
|
|
|
|
... except:
|
|
|
|
... 1/0
|
|
|
|
... except Exception as e:
|
|
|
|
... chained_exc = e
|
|
|
|
...
|
|
|
|
>>> # limit works as with the module-level functions
|
|
|
|
>>> TracebackException.from_exception(exc, limit=-2).print()
|
|
|
|
Traceback (most recent call last):
|
|
|
|
File "<python-input-1>", line 6, in lumberjack
|
|
|
|
bright_side_of_life()
|
|
|
|
~~~~~~~~~~~~~~~~~~~^^
|
|
|
|
File "<python-input-1>", line 10, in bright_side_of_life
|
|
|
|
return t[5]
|
|
|
|
~^^^
|
|
|
|
IndexError: tuple index out of range
|
|
|
|
|
|
|
|
>>> # capture_locals adds local variables in frames
|
|
|
|
>>> TracebackException.from_exception(exc, limit=-2, capture_locals=True).print()
|
|
|
|
Traceback (most recent call last):
|
|
|
|
File "<python-input-1>", line 6, in lumberjack
|
|
|
|
bright_side_of_life()
|
|
|
|
~~~~~~~~~~~~~~~~~~~^^
|
|
|
|
File "<python-input-1>", line 10, in bright_side_of_life
|
|
|
|
return t[5]
|
|
|
|
~^^^
|
|
|
|
t = ("bright", "side", "of", "life")
|
|
|
|
IndexError: tuple index out of range
|
|
|
|
|
|
|
|
>>> # The *chain* kwarg to print() controls whether chained
|
|
|
|
>>> # exceptions are displayed
|
|
|
|
>>> TracebackException.from_exception(chained_exc).print()
|
|
|
|
Traceback (most recent call last):
|
|
|
|
File "<python-input-19>", line 4, in <module>
|
|
|
|
lumberjack()
|
|
|
|
~~~~~~~~~~^^
|
|
|
|
File "<python-input-8>", line 7, in lumberjack
|
|
|
|
bright_side_of_life()
|
|
|
|
~~~~~~~~~~~~~~~~~~~^^
|
|
|
|
File "<python-input-8>", line 11, in bright_side_of_life
|
|
|
|
return t[5]
|
|
|
|
~^^^
|
|
|
|
IndexError: tuple index out of range
|
|
|
|
|
|
|
|
During handling of the above exception, another exception occurred:
|
|
|
|
|
|
|
|
Traceback (most recent call last):
|
|
|
|
File "<python-input-19>", line 6, in <module>
|
|
|
|
1/0
|
|
|
|
~^~
|
|
|
|
ZeroDivisionError: division by zero
|
|
|
|
|
|
|
|
>>> TracebackException.from_exception(chained_exc).print(chain=False)
|
|
|
|
Traceback (most recent call last):
|
|
|
|
File "<python-input-19>", line 6, in <module>
|
|
|
|
1/0
|
|
|
|
~^~
|
|
|
|
ZeroDivisionError: division by zero
|
|
|
|
|