Skip to content

Clarify that import sys.monitoring will **fail** instead of **being unnecessary** #148320

@jonathandung

Description

@jonathandung

Documentation

The sys.monitoring docs, begins with the following note:

sys.monitoring is a namespace within the sys module, not an independent module, so there is no
need to import sys.monitoring, simply import sys and then use sys.monitoring.

However, since sys is a special module, rather than a package (w/ __init__.py), the statement import sys.monitoring emits a ModuleNotFoundError: No module named 'sys.monitoring'; 'sys' is not a package.

I propose to change the .. note:: to a .. warning::, explicitly stating that sys.monitoring, though an instance of types.ModuleType as an attribute of sys, cannot be imported in this fashion.

This is somewhat significant, since one would expect a namespace in sys with a separate page documenting it would be a submodule thereof, especially if they were directed to the page from urls like this, which does not display the top of the page at first.

See the documentation source.

The error applies for sys._jit as well. However, its behaviour is said to be a CPython implementation detail (if it exists, only its attributes can be relied on), and it does not have a separate page for it, so there is no fault.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions