Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frozen modules to sys.stdlib_module_names #87611

Closed
vstinner opened this issue Mar 9, 2021 · 6 comments
Closed

Add frozen modules to sys.stdlib_module_names #87611

vstinner opened this issue Mar 9, 2021 · 6 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir

Comments

@vstinner
Copy link
Member

vstinner commented Mar 9, 2021

BPO 43445
Nosy @nascheme, @vstinner
PRs
  • bpo-43445: Add frozen modules to sys.stdlib_module_names #24798
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-03-10.10:17:25.888>
    created_at = <Date 2021-03-09.10:35:11.149>
    labels = ['library', '3.10']
    title = 'Add frozen modules to sys.stdlib_module_names'
    updated_at = <Date 2021-03-10.10:17:25.888>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2021-03-10.10:17:25.888>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-03-10.10:17:25.888>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2021-03-09.10:35:11.149>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43445
    keywords = ['patch']
    message_count = 6.0
    messages = ['388345', '388374', '388378', '388379', '388418', '388420']
    nosy_count = 2.0
    nosy_names = ['nascheme', 'vstinner']
    pr_nums = ['24798']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue43445'
    versions = ['Python 3.10']

    @vstinner
    Copy link
    Member Author

    vstinner commented Mar 9, 2021

    The sys.stdlib_module_names documentation says: "All module kinds are listed: pure Python, built-in, frozen and extension modules. Test modules are excluded."
    https://docs.python.org/dev/library/sys.html#sys.stdlib_module_names

    But I just noticed that frozen modules are not listed!

    Attached PR fix this issue.

    @vstinner vstinner added 3.10 only security fixes stdlib Python modules in the Lib dir labels Mar 9, 2021
    @nascheme
    Copy link
    Member

    nascheme commented Mar 9, 2021

    Not sure the proper place to discuss this but I wonder if putting this stdlib module names list in the executable is the best idea. The list of available stdlib modules could change after compiling Python. I understand you don't want to dynamically crawl the library path the build the list. That's too slow. However, is there a really strong reason to embed it in the Python executable?

    Did you consider generating a .py module, containing the list. E.g. "_stdlib_modules.py" inside the lib folder. Then, you can have site.py or some similar startup logic import that module and assign it to sys.stdlib_module_names.

    @vstinner
    Copy link
    Member Author

    vstinner commented Mar 9, 2021

    Neil Schemenauer: "Not sure the proper place to discuss this but I wonder if putting this stdlib module names list in the executable is the best idea."

    For the rationale behind sys.stdlib_module_names, please see the bpo-42955 where alternative were discussed.

    @vstinner
    Copy link
    Member Author

    vstinner commented Mar 9, 2021

    The list of available stdlib modules could change after compiling Python.

    It's documented:
    "[ sys.stdlib_module_names] is the same on all platforms. Modules which are not available on some platforms and modules disabled at Python build are also listed."
    https://docs.python.org/dev/library/sys.html#sys.stdlib_module_names

    @vstinner
    Copy link
    Member Author

    New changeset 307745a by Victor Stinner in branch 'master':
    bpo-43445: Add frozen modules to sys.stdlib_module_names (GH-24798)
    307745a

    @vstinner
    Copy link
    Member Author

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants