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

bpo-43445: Add frozen modules to sys.stdlib_module_names #24798

Merged
merged 1 commit into from Mar 10, 2021

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Mar 9, 2021

Add frozen modules to sys.stdlib_module_names. For example, add
"_frozen_importlib" and "_frozen_importlib_external" names.

Add "list_frozen" command to Programs/_testembed.

https://bugs.python.org/issue43445

Add frozen modules to sys.stdlib_module_names. For example, add
"_frozen_importlib" and "_frozen_importlib_external" names.

Add "list_frozen" command to Programs/_testembed.
@vstinner
Copy link
Member Author

@vstinner vstinner commented Mar 9, 2021

@nascheme
Copy link
Member

@nascheme nascheme commented Mar 9, 2021

It seems more useful to me to add a little function to _imp. E.g. _imp.list_frozen_modules(). That's close to the same amount of code as your _testembed change and could be potentially useful in other ways. If you prefer, could be hidden function like _imp._list_frozen_modules(). Returns a list of frozen module names.

@vstinner
Copy link
Member Author

@vstinner vstinner commented Mar 9, 2021

It seems more useful to me to add a little function to _imp. E.g. _imp.list_frozen_modules().

What would be the use case for listing stdlib frozen modules? I didn't add any function because I failed to find an use case.

It seems like sys.builtin_module_names is used in many places since built-in modules are special.

_frozen_importlib and _frozen_importlib_external are really special, since they are the frozen version of Python modules, but under a different name.

The only module which might matter is zipimport. CPython 3.10 exposes it as a frozen module. You can check it using its loader class (FrozenImporter):

$ ./python
Python 3.10.0a6+
>>> import zipimport
>>> zipimport.__loader__
<class '_frozen_importlib.FrozenImporter'>

I guess that the only people who really care are people creating their own Python binary with their own list of frozen modules. But I guess that they know what they put in the binary.

@vstinner vstinner merged commit 307745a into python:master Mar 10, 2021
11 checks passed
11 checks passed
Docs
Details
Check for source changes
Details
Check if generated files are up to date
Details
Windows (x86)
Details
Windows (x64)
Details
macOS
Details
Ubuntu
Details
Azure Pipelines PR #20210309.6 succeeded
Details
Travis CI - Pull Request Build Passed
Details
bedevere/issue-number Issue number 43445 found
Details
bedevere/news News entry found in Misc/NEWS.d
@vstinner vstinner deleted the vstinner:list_frozen branch Mar 10, 2021
@vstinner
Copy link
Member Author

@vstinner vstinner commented Mar 10, 2021

I merged this PR to be able to work on https://bugs.python.org/issue43456

@nascheme: If you consider that it's useful to have an API to list frozen modules, feel free to propose a new PR for that.

Harry-Lees added a commit to Harry-Lees/cpython that referenced this pull request Mar 28, 2021
)

Add frozen modules to sys.stdlib_module_names. For example, add
"_frozen_importlib" and "_frozen_importlib_external" names.

Add "list_frozen" command to Programs/_testembed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants