]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-117953: Split Up _PyImport_LoadDynamicModuleWithSpec() (gh-118203)
authorEric Snow <ericsnowcurrently@gmail.com>
Mon, 29 Apr 2024 15:29:07 +0000 (09:29 -0600)
committerGitHub <noreply@github.com>
Mon, 29 Apr 2024 15:29:07 +0000 (09:29 -0600)
commit44f57a952ea1c25699f19c6cf1fa47cd300e33aa
treef08dbe1ea42d1c003462f09dfcfd20407bc897e0
parent23d0371bb99b1df183c36883e256f82fdf6a4bea
gh-117953: Split Up _PyImport_LoadDynamicModuleWithSpec() (gh-118203)

Basically, I've turned most of _PyImport_LoadDynamicModuleWithSpec() into two new functions (_PyImport_GetModInitFunc() and _PyImport_RunModInitFunc()) and moved the rest of it out into _imp_create_dynamic_impl().  There shouldn't be any changes in behavior.

This change makes some future changes simpler.  This is particularly relevant to potentially calling each module init function in the main interpreter first.  Thus the critical part of the PR is the addition of _PyImport_RunModInitFunc(), which is strictly focused on running the init func and validating the result.  A later PR will take it a step farther by capturing error information rather than raising exceptions.

FWIW, this change also helps readers by clarifying a bit more about what happens when an extension/builtin module is imported.
Include/internal/pycore_import.h
Include/internal/pycore_importdl.h
Include/moduleobject.h
Python/import.c
Python/importdl.c