Skip to content

Docstring of traceback.format_exception_only misses the __notes__ part #111157

Closed
@sobolevn

Description

@sobolevn

Bug report

Compare the docs:

.. function:: format_exception_only(exc, /[, value])
Format the exception part of a traceback using an exception value such as
given by ``sys.last_value``. The return value is a list of strings, each
ending in a newline. The list contains the exception's message, which is
normally a single string; however, for :exc:`SyntaxError` exceptions, it
contains several lines that (when printed) display detailed information
about where the syntax error occurred. Following the message, the list
contains the exception's :attr:`notes <BaseException.__notes__>`.

With the docstring:

cpython/Lib/traceback.py

Lines 151 to 165 in 7237fb5

def format_exception_only(exc, /, value=_sentinel):
"""Format the exception part of a traceback.
The return value is a list of strings, each ending in a newline.
Normally, the list contains a single string; however, for
SyntaxError exceptions, it contains several lines that (when
printed) display detailed information about where the syntax
error occurred.
The message indicating which exception occurred is always the last
string in the list.
"""
if value is _sentinel:

Docstring is missing

Following the message, the list contains the exception's :attr:`notes <BaseException.__notes__>`. 

part.

I think that it would be better to mention __notes__ there as well.
PR is incoming.

Linked PRs

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dirstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions