Skip to content

pydoc inncorrectly assumes a module has documentation and where #139971

Description

@tripleee

Bug report

Bug description:

>>> import encodings
>>> help(encodings)
Help on package encodings:

NAME
    encodings - Standard "encodings" Package

MODULE REFERENCE
    https://docs.python.org/3.14/library/encodings.html
    
    The following documentation is automatically generated from the Python
    source files.  It may be incomplete, incorrect or include features that
    are considered implementation detail and may vary between Python
    implementations.  When in doubt, consult the module reference at the
    location listed above.

DESCRIPTION
        Standard Python encoding modules are stored in this package
        directory.
    
        Codec modules must have names corresponding to normalized encoding
        names as defined in the normalize_encoding() function below, e.g.
        'utf-8' must be implemented by the module 'utf_8.py'.
    
        Each codec module must export the following interface:
[lines 1-23]
>>> print('\n'.join(x for x in pydoc.render_doc(encodings).splitlines() if 'http' in x))
    https://docs.python.org/3.14/library/encodings.html

The URL included here is not valid, and seems to be invalid at least back to Python 3.11.

I can't say if this has been deleted by mistake or if it was cleaned out and the documentation should no longer include it.

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

Activity

  1. terryjreedy commented on Oct 11, 2025

    @terryjreedy
    Member

    Verified on Windows.

  2. changed the title [-]Broken link to encodings.html[/-] [+]Broken link to encodings doc in help(encodings)[/+] on Oct 11, 2025
  3. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Oct 11, 2025
  4. StanFromIreland commented on Oct 11, 2025

    @StanFromIreland
    Member

    This is a pydoc issue, it does not support modules that are documented on the page of another module. In this case, encodings is documented on the codecs page: https://docs.python.org/3/library/codecs.html

  5. changed the title [-]Broken link to encodings doc in help(encodings)[/-] [+]`help` provides incorrect doc link for module documented on the page of a another[/+] on Oct 11, 2025
  6. StanFromIreland commented on Oct 12, 2025

    @StanFromIreland
    Member

    From a duplicate report I see this is also done for private modules, from a quick look at the source, there is indeed no verification that the docs exist, it simply assumes they do and creates the link.

  7. changed the title [-]`help` provides incorrect doc link for module documented on the page of a another[/-] [+]`pydoc` inncorrectly assumes a module has documentation and where[/+] on Oct 12, 2025
  8. StanFromIreland commented on Oct 12, 2025

    @StanFromIreland
    Member

    I will try to write a patch that extends our topics.py generation script to include a dictionary of canonical doc locations.

  9. zware commented on Oct 13, 2025

    @zware
    Member

    See also gh-84232 and associated GH-29419.

  10. StanFromIreland commented on Oct 13, 2025

    @StanFromIreland
    Member

    Ah, that is a duplicate. Which one should we close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions