diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-08-02 17:00:57 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2018-08-02 17:00:57 (GMT) |
commit | 295342adbfd905d5b4a77f960ea39649df7d9997 (patch) | |
tree | 54dcfe87b4963f3f10e0e9033b674f96c12824af /Lib/traceback.py | |
parent | 8c4a0059accb5cb33e90ec5b2f3e9dc08e2f3048 (diff) | |
download | cpython-295342adbfd905d5b4a77f960ea39649df7d9997.zip cpython-295342adbfd905d5b4a77f960ea39649df7d9997.tar.gz cpython-295342adbfd905d5b4a77f960ea39649df7d9997.tar.bz2 |
bpo-27910: Update documentation of traceback module (GH-6116)
In the documentation for the traceback module, the definitions of functions
extract_tb(), format_list() and classmethod StackSummary.from_list()
mention the old style 4-tuples that these functions used to return or accept.
Since Python 3.5, however, they return or accept a FrameSummary object
instead of a 4-tuple, or a StackSummary object instead of a list of 4-tuples.
Co-authored-by: torsava <torsava@redhat.com>
Co-Authored-By: Berker Peksag <berker.peksag@gmail.com>
(cherry picked from commit f394ee5eaf6d6d8f45e0478e77d4dbff25c6bea7)
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r-- | Lib/traceback.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py index 41fefff..d2b102b 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -25,10 +25,12 @@ def print_list(extracted_list, file=None): print(item, file=file, end="") def format_list(extracted_list): - """Format a list of traceback entry tuples for printing. + """Format a list of tuples or FrameSummary objects for printing. + + Given a list of tuples or FrameSummary objects as returned by + extract_tb() or extract_stack(), return a list of strings ready + for printing. - Given a list of tuples as returned by extract_tb() or - 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 @@ -55,15 +57,17 @@ def format_tb(tb, limit=None): return extract_tb(tb, limit=limit).format() def extract_tb(tb, limit=None): - """Return list of up to limit pre-processed entries from traceback. + """ + Return a StackSummary object representing a list of + pre-processed entries from traceback. This is useful for alternate formatting of stack traces. If 'limit' is omitted or None, all entries are extracted. A - pre-processed stack trace entry is a quadruple (filename, line - number, function name, text) representing the information that is - usually printed for a stack trace. The text is a string with - leading and trailing whitespace stripped; if the source is not - available it is None. + pre-processed stack trace entry is a FrameSummary object + containing attributes filename, lineno, name, and line + representing the information that is usually printed for a stack + trace. The line is a string with leading and trailing + whitespace stripped; if the source is not available it is None. """ return StackSummary.extract(walk_tb(tb), limit=limit) @@ -360,10 +364,9 @@ class StackSummary(list): @classmethod def from_list(klass, a_list): - """Create a StackSummary from a simple list of tuples. - - This method supports the older Python API. Each tuple should be a - 4-tuple with (filename, lineno, name, line) elements. + """ + Create a StackSummary object from a supplied list of + FrameSummary objects or old-style list of tuples. """ # While doing a fast-path check for isinstance(a_list, StackSummary) is # appealing, idlelib.run.cleanup_traceback and other similar code may |