Skip to content

help CLI shows a traceback when import failed #102541

Closed
@Eclips4

Description

@Eclips4

Currently, help will show a traceback when we type name of something which doesn't exist:

help> 123
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen _sitebuiltins>", line 103, in __call__
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 2004, in __call__
    self.interact()
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 2031, in interact
    self.help(request)
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 2057, in help
    elif request: doc(request, 'Help on %s:', output=self._output)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 1781, in doc
    pager(render_doc(thing, title, forceload))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 1755, in render_doc
    object, name = resolve(thing, forceload)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\KIRILL-1\CLionProjects\cpython\Lib\pydoc.py", line 1741, in resolve
    raise ImportError('''\
ImportError: No Python documentation found for '123'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
>>>

I think, this shouldn't be shown.
Is there any reason for this?
Can we show something like
No python documentation found for '123'.?

Reproducible on current main.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13bugs and security fixesrelease-blockertype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions