Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Open
@ericsnowcurrently

Description

@ericsnowcurrently
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.