1-
21:mod: `traceback ` --- Print or retrieve a stack traceback
32========================================================
43
@@ -29,29 +28,31 @@ The module defines the following functions:
2928 object to receive the output.
3029
3130
32- .. function :: print_exception(type, value, traceback[, limit[, file]])
31+ .. function :: print_exception(type, value, traceback[, limit[, file[, chain] ]])
3332
3433 Print exception information and up to *limit * stack trace entries from
35- *traceback * to *file *. This differs from :func: `print_tb ` in the following ways:
36- (1) if *traceback * is not ``None ``, it prints a header ``Traceback (most recent
37- call last): ``; (2) it prints the exception *type * and *value * after the stack
38- trace; (3) if *type * is :exc: `SyntaxError ` and *value * has the appropriate
39- format, it prints the line where the syntax error occurred with a caret
40- indicating the approximate position of the error.
41-
34+ *traceback * to *file *. This differs from :func: `print_tb ` in the following
35+ ways:
4236
43- .. function :: print_exc([limit[, file]])
37+ * if *traceback * is not ``None ``, it prints a header ``Traceback (most recent
38+ call last): ``
39+ * it prints the exception *type * and *value * after the stack trace
40+ * if *type * is :exc: `SyntaxError ` and *value * has the appropriate format, it
41+ prints the line where the syntax error occurred with a caret indicating the
42+ approximate position of the error.
4443
45- This is a shorthand for ``print_exception(*sys.exc_info()) ``.
44+ If *chain * is true (the default), then chained exceptions (the
45+ :attr: `__cause__ ` or :attr: `__context__ ` attributes of the exception) will be
46+ printed as well, like the interpreter itself does when printing an unhandled
47+ exception.
4648
4749
48- .. function :: format_exc ([limit])
50+ .. function :: print_exc ([limit[, file[, chain]] ])
4951
50- This is like ``print_exc(limit) `` but returns a string instead of printing to a
51- file.
52+ This is a shorthand for ``print_exception(*sys.exc_info()) ``.
5253
5354
54- .. function :: print_last([limit[, file]])
55+ .. function :: print_last([limit[, file[, chain] ]])
5556
5657 This is a shorthand for ``print_exception(sys.last_type, sys.last_value,
5758 sys.last_traceback, limit, file) ``.
@@ -103,7 +104,7 @@ The module defines the following functions:
103104 occurred is the always last string in the list.
104105
105106
106- .. function :: format_exception(type, value, tb[, limit])
107+ .. function :: format_exception(type, value, tb[, limit[, chain] ])
107108
108109 Format a stack trace and the exception information. The arguments have the
109110 same meaning as the corresponding arguments to :func: `print_exception `. The
@@ -112,6 +113,12 @@ The module defines the following functions:
112113 same text is printed as does :func: `print_exception `.
113114
114115
116+ .. function :: format_exc([limit[, chain]])
117+
118+ This is like ``print_exc(limit) `` but returns a string instead of printing to a
119+ file.
120+
121+
115122.. function :: format_tb(tb[, limit])
116123
117124 A shorthand for ``format_list(extract_tb(tb, limit)) ``.
0 commit comments