Skip to content

Python3.11: invalid help query raises an ImportError #98374

Closed
@qexat

Description

@qexat

Bug report

Running this on Python 3.11 REPL:

>>> help("invalid query")

Raises the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen _sitebuiltins>", line 103, in __call__
  File "/usr/lib/python3.11/pydoc.py", line 2001, in __call__
    self.help(request)
  File "/usr/lib/python3.11/pydoc.py", line 2057, in help
    elif request: doc(request, 'Help on %s:', output=self._output)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pydoc.py", line 1784, in doc
    pager(render_doc(thing, title, forceload))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pydoc.py", line 1758, in render_doc
    object, name = resolve(thing, forceload)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pydoc.py", line 1744, in resolve
    raise ImportError('''\
ImportError: No Python documentation found for 'invalid query'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

Python 3.10.8 (and most probably any 3.10.*) simply prints this:

No Python documentation found for 'invalid query'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

Your environment

  • CPython versions tested on: 3.11.0, 3.10.8
  • Operating system and architecture: EndeavourOS, kernel: 6.0.1-arch2-1 (64-bit)

Apparently, this is due to commit 8868d48712aee2b490efaf60bed8dfe9fb14d6b7 (thanks to @asottile for finding it).

Is it expected behavior though?

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions