Skip to content

bpo-29660: traceback: Document that etype is ignored in some places. #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Doc/library/traceback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ The module defines the following functions:
* if *tb* is not ``None``, it prints a header ``Traceback (most recent
call last):``
* it prints the exception *etype* and *value* after the stack trace
* if *etype* 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.
* 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.

The optional *limit* argument has the same meaning as for :func:`print_tb`.
If *chain* is true (the default), then chained exceptions (the
:attr:`__cause__` or :attr:`__context__` attributes of the exception) will be
printed as well, like the interpreter itself does when printing an unhandled
exception.

.. versionchanged:: 3.5
The *etype* argument is ignored and inferred from the type of *value*.


.. function:: print_exc(limit=None, file=None, chain=True)

Expand Down Expand Up @@ -131,6 +134,9 @@ The module defines the following functions:
containing internal newlines. When these lines are concatenated and printed,
exactly the same text is printed as does :func:`print_exception`.

.. versionchanged:: 3.5
The *etype* argument is ignored and inferred from the type of *value*.


.. function:: format_exc(limit=None, chain=True)

Expand Down Expand Up @@ -372,6 +378,7 @@ exception and traceback:
print("*** print_tb:")
traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
print("*** print_exception:")
# exc_type below is ignored on 3.5 and later
traceback.print_exception(exc_type, exc_value, exc_traceback,
limit=2, file=sys.stdout)
print("*** print_exc:")
Expand All @@ -381,6 +388,7 @@ exception and traceback:
print(formatted_lines[0])
print(formatted_lines[-1])
print("*** format_exception:")
# exc_type below is ignored on 3.5 and later
print(repr(traceback.format_exception(exc_type, exc_value,
exc_traceback)))
print("*** extract_tb:")
Expand Down