GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-117953: Track All Extension Modules by ericsnowcurrently · Pull Request #118156 · python/cpython

Conversation

@ericsnowcurrently

@ericsnowcurrently ericsnowcurrently commented Apr 22, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

When an extension module is loaded, the init function is looked up and run. If that doesn't fail then the module is "fixed up", which includes adding its PyModuleDef to a global mapping that is used if the module is re-loaded. However, that has not applied to multi-phase init modules. Adding those modules to the global mapping would identify that we already loaded the module (or at least tried), as well as the module's kind. That's especially useful for a follow up PR I have planned.

(This is based on gh-118116. For the diff, see my track-all-ext-modules branch.)

  • Issue: Single-Phase Init Extension Module Init Functions Still Run in Isolated Interpreters #117953

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ericsnowcurrently added 30 commits April 16, 2024 11:10
@ericsnowcurrently
Factor out _PyImport_RunDynamicModule().
cc67849
@ericsnowcurrently
Drop _PyImport_LoadDynamicModuleWithSpec().
2e5ecde
@ericsnowcurrently
Add an assert.
b810cd8
@ericsnowcurrently
Factor out fix_up_extension_for_interpreter().
8d0ef38
@ericsnowcurrently
Do _extensions_cache_set() first.
7f930cc
@ericsnowcurrently
Calculate path_bytes ahead of time.
1ffeaef
@ericsnowcurrently
Move the audit entry to _imp_create_dynamic_impl().
7500285
@ericsnowcurrently
_Py_ext_module_loader_info_from_spec() -> _Py_ext_module_loader_info_…
3c0b170
…init_from_spec()
@ericsnowcurrently
Add info.newcontext.
02e24cc
@ericsnowcurrently
Split up _PyImport_RunDynamicModule() along cross-interpreter-safe bo…
ba5ffa7
…undaries.
@ericsnowcurrently
Drop _PyImport_RunDynamicModule().
b895966
@ericsnowcurrently
Always close the file handle.
76fa273
@ericsnowcurrently
Revert the fclose() change.
1e936c5
@ericsnowcurrently
Factor out create_dynamic().
6bb07b9
@ericsnowcurrently
Drop _PyImport_FixupExtensionObject().
2705e65
@ericsnowcurrently
Move setting __file__ to fix_up_extension().
98d8b4b
@ericsnowcurrently
Pass tstate through to fix_up_extension().
ddf1135
@ericsnowcurrently
Add a note about _PyImport_FixupBuiltin().
694a763
@ericsnowcurrently
Always expect a valid modules dict passed to fix_up_extension().
72e0d73
@ericsnowcurrently
Factor out reload_singlephase_extension().
3f14a67
@ericsnowcurrently
res.singlephase -> res.kind
b5f5868
@ericsnowcurrently
Factor out _extensions_cache_init().
a5f7535
@ericsnowcurrently
Factor out _extensions_cache_find_unlocked().
e8d674a
@ericsnowcurrently
Use _PyImport_RunModInitFunc() in create_builtin().
27b365d
@ericsnowcurrently
Clean up _PyImport_FixupBuiltin().
5128702
@ericsnowcurrently
Add some asserts to _PyImport_RunModInitFunc().
aaec360
@ericsnowcurrently
Drop the replace arg to _extensions_cache_set().
f97671e
@ericsnowcurrently
Check the module returned by import_find_extension() to ensure single…
2366983
…-phase init.
@ericsnowcurrently
Allow mod->md_def to be NULL.
d5039ea
@ericsnowcurrently
Call _PyImport_RunModInitFunc() in reload_singlephase_extension().
67d217b
ericsnowcurrently added 12 commits April 18, 2024 19:14
@ericsnowcurrently
Factor out update_extension_cache() and drop fix_up_extension_for_int…
967c649
…erpreter().
@ericsnowcurrently
We already know the def is okay.
aecf56c
@ericsnowcurrently
Revive fix_up_extension_for_interpreter().
0d03d23
@ericsnowcurrently
Add a distinct _Py_ext_module_loader_info.path (and old path -> filen…
cace102
…ame).
@ericsnowcurrently
Do not call update_extensions_cache() in fix_up_extension().
3cf0db0
@ericsnowcurrently
Let the modules arg to fix_up_extension_for_interpreter() be NULL.
9b3088a
@ericsnowcurrently
Let the caller of update_extensions_cache() decide if m_copy should b…
4ac1644
…e populated.
@ericsnowcurrently
Fix the update_extensions_cache() signature.
393a177
@ericsnowcurrently
Imply singlephase if the init func fails.
2969e4c
@ericsnowcurrently
Keep track of all module defs.
93c7f79
@ericsnowcurrently
Fix the implementation.
cb2137e
@ericsnowcurrently
wip
895ce51
@ericsnowcurrently ericsnowcurrently added the skip news label Apr 22, 2024
@ericsnowcurrently
ericsnowcurrently requested review from brettcannon, kumaraditya303, ncoghlan and warsaw as code owners April 22, 2024 15:31
@bedevere-app bedevere-app Bot mentioned this pull request Apr 22, 2024
Single-Phase Init Extension Module Init Functions Still Run in Isolated Interpreters #117953
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Apr 22, 2024
@ericsnowcurrently ericsnowcurrently mentioned this pull request Apr 22, 2024
gh-117953: Always Run Extension Init Func in Main Interpreter First #118157
Merged
@ericsnowcurrently
ericsnowcurrently removed request for brettcannon, kumaraditya303, ncoghlan and warsaw May 7, 2024 19:57
@ericsnowcurrently
ericsnowcurrently marked this pull request as draft May 7, 2024 19:57
@bedevere-app bedevere-app Bot removed the awaiting core review label May 7, 2024
@github-actions

github-actions Bot commented Apr 16, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 16, 2026
@ambv

ambv commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

This PR is attached to gh-117953, which is already completed: the fix for that issue landed through other changes, and this PR's approach was not taken or has since become obsolete. Closing to cull the number of open pull requests. Do not reopen this pull request without getting a go-ahead from a triager or core developer.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ambv ambv closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity ZeroIntensity will be requested when the pull request is marked ready for review ZeroIntensity is a code owner
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 will be requested when the pull request is marked ready for review FFY00 is a code owner
@brettcannon brettcannon Awaiting requested review from brettcannon brettcannon will be requested when the pull request is marked ready for review brettcannon is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan will be requested when the pull request is marked ready for review ncoghlan is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw will be requested when the pull request is marked ready for review warsaw is a code owner
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 will be requested when the pull request is marked ready for review kumaraditya303 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ericsnowcurrently @ambv
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.