Skip to content

Docstring of traceback.format_exception_only misses the __notes__ part #111157

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

Closed
sobolevn opened this issue Oct 21, 2023 · 0 comments
Closed

Docstring of traceback.format_exception_only misses the __notes__ part #111157

sobolevn opened this issue Oct 21, 2023 · 0 comments
Assignees
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Oct 21, 2023

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

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error docs Documentation in the Doc dir stdlib Python modules in the Lib dir labels Oct 21, 2023
@sobolevn sobolevn self-assigned this Oct 21, 2023
@sobolevn sobolevn changed the title Docstring of traceback.format_exception_only is misleading Docstring of traceback.format_exception_only misses the __notes__ part Oct 21, 2023
sobolevn added a commit to sobolevn/cpython that referenced this issue Oct 21, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 21, 2023
…nly` docstring (pythonGH-111158)

(cherry picked from commit 5e7727b)

Co-authored-by: Nikita Sobolev <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 21, 2023
…nly` docstring (pythonGH-111158)

(cherry picked from commit 5e7727b)

Co-authored-by: Nikita Sobolev <[email protected]>
iritkatriel pushed a commit that referenced this issue Oct 21, 2023
…only` docstring (GH-111158) (#111164)

gh-111157: Mention `__notes__` in `traceback.format_exception_only` docstring (GH-111158)
(cherry picked from commit 5e7727b)

Co-authored-by: Nikita Sobolev <[email protected]>
iritkatriel pushed a commit that referenced this issue Oct 21, 2023
…only` docstring (GH-111158) (#111163)

gh-111157: Mention `__notes__` in `traceback.format_exception_only` docstring (GH-111158)
(cherry picked from commit 5e7727b)

Co-authored-by: Nikita Sobolev <[email protected]>
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants