Skip to content

Docstring of traceback.format_exception_only misses the __notes__ part #111157

Closed

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

Activity

  1. added
    type-bug
    docs
    stdlib
    on Oct 21, 2023
  2. self-assigned this
    on Oct 21, 2023
  3. changed the title [-]Docstring of `traceback.format_exception_only` is misleading[/-] [+]Docstring of `traceback.format_exception_only` misses the `__notes__` part[/+] on Oct 21, 2023
  4. added a commit that references this issue on Oct 21, 2023
  5. added a commit that references this issue on Oct 21, 2023
  6. added 2 commits that reference this issue on Oct 21, 2023
  7. added 2 commits that reference this issue on Oct 21, 2023
  8. added a commit that references this issue on Feb 11, 2024
  9. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

docsstdlibtype-bug

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions