Issue26035 - Correct the argument names used in the docs of the traceback module. Make it consistent with module args.

This commit is contained in:
Senthil Kumaran 2016-01-15 22:13:16 -08:00
parent 2179b2e159
commit 11a73890d3
1 changed files with 51 additions and 48 deletions

View File

@ -14,29 +14,30 @@ interpreter.
.. index:: object: traceback .. index:: object: traceback
The module uses traceback objects --- this is the object type that is stored in The module uses traceback objects --- this is the object type that is stored in
the variables :data:`sys.exc_traceback` (deprecated) and :data:`sys.last_traceback` and the variables :data:`sys.exc_traceback` (deprecated) and
returned as the third item from :func:`sys.exc_info`. :data:`sys.last_traceback` and returned as the third item from
:func:`sys.exc_info`.
The module defines the following functions: The module defines the following functions:
.. function:: print_tb(traceback[, limit[, file]]) .. function:: print_tb(tb[, limit[, file]])
Print up to *limit* stack trace entries from *traceback*. If *limit* is omitted Print up to *limit* stack trace entries from the traceback object *tb*. If
or ``None``, all entries are printed. If *file* is omitted or ``None``, the *limit* is omitted or ``None``, all entries are printed. If *file* is omitted
output goes to ``sys.stderr``; otherwise it should be an open file or file-like or ``None``, the output goes to ``sys.stderr``; otherwise it should be an
object to receive the output. open file or file-like object to receive the output.
.. function:: print_exception(type, value, traceback[, limit[, file]]) .. function:: print_exception(etype, value, tb[, limit[, file]])
Print exception information and up to *limit* stack trace entries from Print exception information and up to *limit* stack trace entries from the
*traceback* to *file*. This differs from :func:`print_tb` in the following ways: traceback *tb* to *file*. This differs from :func:`print_tb` in the following
(1) if *traceback* is not ``None``, it prints a header ``Traceback (most recent ways: (1) if *tb* is not ``None``, it prints a header ``Traceback (most
call last):``; (2) it prints the exception *type* and *value* after the stack recent call last):``; (2) it prints the exception *etype* and *value* after
trace; (3) if *type* is :exc:`SyntaxError` and *value* has the appropriate the stack trace; (3) if *etype* is :exc:`SyntaxError` and *value* has the
format, it prints the line where the syntax error occurred with a caret appropriate format, it prints the line where the syntax error occurred with a
indicating the approximate position of the error. caret indicating the approximate position of the error.
.. function:: print_exc([limit[, file]]) .. function:: print_exc([limit[, file]])
@ -49,8 +50,8 @@ The module defines the following functions:
.. function:: format_exc([limit]) .. function:: format_exc([limit])
This is like ``print_exc(limit)`` but returns a string instead of printing to a This is like ``print_exc(limit)`` but returns a string instead of printing to
file. a file.
.. versionadded:: 2.4 .. versionadded:: 2.4
@ -64,21 +65,21 @@ The module defines the following functions:
.. function:: print_stack([f[, limit[, file]]]) .. function:: print_stack([f[, limit[, file]]])
This function prints a stack trace from its invocation point. The optional *f* This function prints a stack trace from its invocation point. The optional
argument can be used to specify an alternate stack frame to start. The optional *f* argument can be used to specify an alternate stack frame to start. The
*limit* and *file* arguments have the same meaning as for optional limit* and *file* arguments have the same meaning as for
:func:`print_exception`. :func:`print_exception`.
.. function:: extract_tb(traceback[, limit]) .. function:: extract_tb(tb[, limit])
Return a list of up to *limit* "pre-processed" stack trace entries extracted Return a list of up to *limit* "pre-processed" stack trace entries extracted
from the traceback object *traceback*. It is useful for alternate formatting of from the traceback object *tb*. It is useful for alternate formatting of
stack traces. If *limit* is omitted or ``None``, all entries are extracted. A stack traces. If *limit* is omitted or ``None``, all entries are extracted.
"pre-processed" stack trace entry is a 4-tuple (*filename*, *line number*, A "pre-processed" stack trace entry is a 4-tuple (*filename*, *line number*,
*function name*, *text*) representing the information that is usually printed function name*, *text*) representing the information that is usually printed
for a stack trace. The *text* is a string with leading and trailing whitespace for a stack trace. The *text* is a string with leading and trailing
stripped; if the source is not available it is ``None``. whitespace stripped; if the source is not available it is ``None``.
.. function:: extract_stack([f[, limit]]) .. function:: extract_stack([f[, limit]])
@ -88,33 +89,35 @@ The module defines the following functions:
arguments have the same meaning as for :func:`print_stack`. arguments have the same meaning as for :func:`print_stack`.
.. function:: format_list(list) .. function:: format_list(extracted_list)
Given a list of tuples as returned by :func:`extract_tb` or Given a list of tuples as returned by :func:`extract_tb` or
:func:`extract_stack`, return a list of strings ready for printing. Each string :func:`extract_stack`, return a list of strings ready for printing. Each
in the resulting list corresponds to the item with the same index in the string in the resulting list corresponds to the item with the same index in
argument list. Each string ends in a newline; the strings may contain internal the argument list. Each string ends in a newline; the strings may contain
newlines as well, for those items whose source text line is not ``None``. internal newlines as well, for those items whose source text line is not
``None``.
.. function:: format_exception_only(type, value) .. function:: format_exception_only(etype, value)
Format the exception part of a traceback. The arguments are the exception type Format the exception part of a traceback. The arguments are the exception
and value such as given by ``sys.last_type`` and ``sys.last_value``. The return type, *etype* and *value* such as given by ``sys.last_type`` and
value is a list of strings, each ending in a newline. Normally, the list ``sys.last_value``. The return value is a list of strings, each ending in a
contains a single string; however, for :exc:`SyntaxError` exceptions, it newline. Normally, the list contains a single string; however, for
contains several lines that (when printed) display detailed information about :exc:`SyntaxError` exceptions, it contains several lines that (when printed)
where the syntax error occurred. The message indicating which exception display detailed information about where the syntax error occurred. The
occurred is the always last string in the list. message indicating which exception occurred is the always last string in the
list.
.. function:: format_exception(type, value, tb[, limit]) .. function:: format_exception(etype, value, tb[, limit])
Format a stack trace and the exception information. The arguments have the Format a stack trace and the exception information. The arguments have the
same meaning as the corresponding arguments to :func:`print_exception`. The same meaning as the corresponding arguments to :func:`print_exception`. The
return value is a list of strings, each ending in a newline and some containing return value is a list of strings, each ending in a newline and some
internal newlines. When these lines are concatenated and printed, exactly the containing internal newlines. When these lines are concatenated and printed,
same text is printed as does :func:`print_exception`. exactly the same text is printed as does :func:`print_exception`.
.. function:: format_tb(tb[, limit]) .. function:: format_tb(tb[, limit])
@ -129,10 +132,10 @@ The module defines the following functions:
.. function:: tb_lineno(tb) .. function:: tb_lineno(tb)
This function returns the current line number set in the traceback object. This This function returns the current line number set in the traceback object.
function was necessary because in versions of Python prior to 2.3 when the This function was necessary because in versions of Python prior to 2.3 when
:option:`-O` flag was passed to Python the ``tb.tb_lineno`` was not updated the :option:`-O` flag was passed to Python the ``tb.tb_lineno`` was not
correctly. This function has no use in versions past 2.3. updated correctly. This function has no use in versions past 2.3.
.. _traceback-example: .. _traceback-example: