bpo-27910: Update documentation of traceback module (GH-6116) · python/cpython@295342a (original) (raw)

`@@ -25,10 +25,12 @@ def print_list(extracted_list, file=None):

`

25

25

`print(item, file=file, end="")

`

26

26

``

27

27

`def format_list(extracted_list):

`

28

``

`-

"""Format a list of traceback entry tuples for printing.

`

``

28

`+

"""Format a list of tuples or FrameSummary objects for printing.

`

``

29

+

``

30

`+

Given a list of tuples or FrameSummary objects as returned by

`

``

31

`+

extract_tb() or extract_stack(), return a list of strings ready

`

``

32

`+

for printing.

`

29

33

``

30

``

`-

Given a list of tuples as returned by extract_tb() or

`

31

``

`-

extract_stack(), return a list of strings ready for printing.

`

32

34

` Each string in the resulting list corresponds to the item with the

`

33

35

` same index in the argument list. Each string ends in a newline;

`

34

36

` the strings may contain internal newlines as well, for those items

`

`@@ -55,15 +57,17 @@ def format_tb(tb, limit=None):

`

55

57

`return extract_tb(tb, limit=limit).format()

`

56

58

``

57

59

`def extract_tb(tb, limit=None):

`

58

``

`-

"""Return list of up to limit pre-processed entries from traceback.

`

``

60

`+

"""

`

``

61

`+

Return a StackSummary object representing a list of

`

``

62

`+

pre-processed entries from traceback.

`

59

63

``

60

64

` This is useful for alternate formatting of stack traces. If

`

61

65

` 'limit' is omitted or None, all entries are extracted. A

`

62

``

`-

pre-processed stack trace entry is a quadruple (filename, line

`

63

``

`-

number, function name, text) representing the information that is

`

64

``

`-

usually printed for a stack trace. The text is a string with

`

65

``

`-

leading and trailing whitespace stripped; if the source is not

`

66

``

`-

available it is None.

`

``

66

`+

pre-processed stack trace entry is a FrameSummary object

`

``

67

`+

containing attributes filename, lineno, name, and line

`

``

68

`+

representing the information that is usually printed for a stack

`

``

69

`+

trace. The line is a string with leading and trailing

`

``

70

`+

whitespace stripped; if the source is not available it is None.

`

67

71

` """

`

68

72

`return StackSummary.extract(walk_tb(tb), limit=limit)

`

69

73

``

`@@ -360,10 +364,9 @@ def extract(klass, frame_gen, *, limit=None, lookup_lines=True,

`

360

364

``

361

365

`@classmethod

`

362

366

`def from_list(klass, a_list):

`

363

``

`-

"""Create a StackSummary from a simple list of tuples.

`

364

``

-

365

``

`-

This method supports the older Python API. Each tuple should be a

`

366

``

`-

4-tuple with (filename, lineno, name, line) elements.

`

``

367

`+

"""

`

``

368

`+

Create a StackSummary object from a supplied list of

`

``

369

`+

FrameSummary objects or old-style list of tuples.

`

367

370

` """

`

368

371

`# While doing a fast-path check for isinstance(a_list, StackSummary) is

`

369

372

`# appealing, idlelib.run.cleanup_traceback and other similar code may

`