Skip to content

Missing Signature Info for Builtin Exceptions in help() and Docs #111405

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

Open
ericsnowcurrently opened this issue Oct 27, 2023 · 1 comment
Open
Labels
3.11 only security fixes 3.12 only security fixes 3.13 bugs and security fixes docs Documentation in the Doc dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@ericsnowcurrently
Copy link
Member

ericsnowcurrently commented Oct 27, 2023

Bug report

Bug description:

(I've tagged this as a "docs" issue because help() is arguably a part of the documentation. Also, some of the docs entries have a similar lack of details. I suppose that could be dealt with separately.)

The help() text for (at least some) builtin exceptions doesn't show the type-specific signature for __init__() (or __new__()), instead showing a generic one with (self, /, *args, **kwargs).

Here's an example (in the REPL) 1:

>>> help(ExceptionGroup)
 | ...
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 | ...

(The help() entry for __new__() is likewise unhelpful.)

There is a similar lack of information in the docs, though a handful of entries have at least some signature information.

All builtin exceptions (best effort catalog):

exception type expected* (approximately)
(incl. additional forms)
docs
have
sig
Exception
BaseException
__init__(self, /, *args)
ExceptionGroup
BaseExceptionGroup
__init__(self, msg, excs, /) X†
StopIteration __init__(self, value=None, /, *args)
SystemExit __init__(self, code=None, /, *args)
ImportError __init__(self, /, name=None, path=None, name_from=None)
OSError __init__(self, errno, strerror, filename=None, winerror=None, filename2=None, /) X†
^^^^^ __init__(self, arg=None, /) X†
^^^^^ __init__(self, /, *args)
NameError __init__(self, /, *args, name=None)
AttributeError __init__(self, /, *args, name=None, obj=None)
SyntaxError __init__(self, msg, details, /) X†
^^^^^ __init__(self, msg=None, /, *args)
UnicodeEncodeError __init__(self, encoding, obj, start, end, reason, /)
UnicodeDecodeError __init__(self, encoding, obj, start, end, reason, /)
UnicodeTranslateError __init__(self, obj, start, end, reason, /)
-- all others (?) -- -- same as Exception/BaseException --

* I derived expected signatures from the content of Objects/exceptions.c.
† The doc entries for OSError, ExceptionGroup, and SyntaxError imply that they each take keyword arguments but they do not.
‡ The doc entries for OSError and SyntaxError do not include the alternate signature.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Footnotes

  1. FYI, I don't mean to pick on ExceptionGroup. It happened to be the one for which I first noticed the problem.

@ericsnowcurrently ericsnowcurrently added type-bug An unexpected behavior, bug, or error docs Documentation in the Doc dir interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.11 only security fixes 3.12 only security fixes 3.13 bugs and security fixes labels Oct 27, 2023
@brian030128
Copy link

Hi I would like to work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 only security fixes 3.13 bugs and security fixes docs Documentation in the Doc dir interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants