This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: The frozen importer should capture info in find_spec().
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.snow Nosy List: barry, eric.snow
Priority: normal Keywords: patch

Created on 2021-09-29 17:57 by eric.snow, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 28633 merged eric.snow, 2021-09-29 18:18
PR 28740 merged eric.snow, 2021-10-05 16:09
Messages (3)
msg402895 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2021-09-29 17:57
Currently FrozenImporter (in Lib/importlib/_bootstrap.py) does minimal work in its find_spec() method.  It only checks whether or not the module is frozen.  However, in doing so it has gathered all the info we need to load the module.  We end up repeating that work in exec_module().

Rather than duplicating that effort, we should preserve the info in spec.loader_state.  This has the added benefit of aligning more closely with the division between finder and loader.  Once we get to the loader, there shouldn't be a need to check if the module is frozen nor otherwise interact with the internal frozen module state (i.e. PyImport_FrozenModules).
msg402896 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2021-09-29 17:58
Taking care of this will also be necessary (probably) as we work on adding __file__ to frozen stdlib modules.  (See bpo-21736.)
msg403247 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2021-10-05 16:01
New changeset c3d9ac8b340fcbf54cee865737e67f11fcd70ed3 by Eric Snow in branch 'main':
bpo-45324: Capture data in FrozenImporter.find_spec() to use in exec_module(). (gh-28633)
https://github.com/python/cpython/commit/c3d9ac8b340fcbf54cee865737e67f11fcd70ed3
History
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89487
2021-10-05 16:09:57eric.snowsetpull_requests: + pull_request27087
2021-10-05 16:02:33eric.snowsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-10-05 16:01:35eric.snowsetmessages: + msg403247
2021-09-29 18:18:01eric.snowsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request27002
2021-09-29 18:07:16barrysetnosy: + barry
2021-09-29 17:58:40eric.snowsetmessages: + msg402896
2021-09-29 17:57:04eric.snowcreate