Skip to content

Reflect it that sys.lazy_modules is no longer a flat set #145057

Description

@johnslavik

Bug report

Bug description:

sys.lazy_modules is now a dict[str, set[str]], not a flat set. There's some places in the stdlib code that incorrectly suggests the older invariant.

Most notable example:

def test_lazy_modules_attribute_is_set(self):
"""sys.lazy_modules should be a set per PEP 810."""
self.assertIsInstance(sys.lazy_modules, dict)

The PEP needs updating as well -- https://peps.python.org/pep-0810/#lazy-import-mechanism -- @DinoV, I think this is something you were working on, or is it open for contrib?

I'm happy to pick this one up (i.e. fixing our code to reflect sys.lazy_modules is a dict) if you'd like that! (Please reassign otherwise.)

cc @pablogsal @DinoV @brittanyrey @Yhg1s

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. self-assigned this
    on Feb 20, 2026
  2. added
    type-bugAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directory
    3.15bugs and security fixes
    on Feb 20, 2026
  3. VanshAgarwal24036 commented on Feb 26, 2026

    @VanshAgarwal24036
    Contributor

    Hi @johnslavik — I noticed this issue is self-assigned.
    If you’re actively working on it, I’ll hold off. If not, I’d be happy to help with updating tests and docs

  4. johnslavik commented on Feb 26, 2026

    @johnslavik
    MemberAuthor

    I'm working on that, but thanks for chiming in!

  5. added a commit that references this issue on Mar 27, 2026
  6. added a commit that references this issue on Apr 16, 2026
  7. added a commit that references this issue on Apr 25, 2026
  8. added a commit that references this issue on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.15bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-lazy-importstype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions