cpython/Include/internal
Eric Snow 44f57a952e
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.
2024-04-29 09:29:07 -06:00
..
mimalloc gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435) 2024-03-06 09:42:11 -05:00
pycore_abstract.h gh-106320: Remove private AC converter functions (#108505) 2023-08-26 04:05:17 +02:00
pycore_asdl.h
pycore_ast.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_ast_state.h gh-106905: Use separate structs to track recursion depth in each PyAST_mod2obj call. (GH-113035) 2023-12-25 19:36:59 +02:00
pycore_atexit.h gh-76785: Rename _xxsubinterpreters to _interpreters (gh-117791) 2024-04-24 16:18:24 +00:00
pycore_backoff.h gh-117549: Match declaration order for _Py_BackoffCounter initializer (#117551) 2024-04-04 14:14:35 -07:00
pycore_bitutils.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_blocks_output_buffer.h gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221) 2023-08-21 19:15:52 +02:00
pycore_brc.h gh-110481: Implement inter-thread queue for biased reference counting (#114824) 2024-02-09 17:08:32 -05:00
pycore_bytes_methods.h gh-117431: Adapt bytes and bytearray .find() and friends to Argument Clinic (#117502) 2024-04-12 07:40:55 +00:00
pycore_bytesobject.h gh-107211: No longer export internal functions (5) (#108423) 2023-08-24 16:06:53 +00:00
pycore_call.h gh-112026: Restore removed private C API (#112115) 2023-11-15 16:38:31 +00:00
pycore_capsule.h gh-108240: Add pycore_capsule.h internal header file (#108596) 2023-08-29 01:20:02 +00:00
pycore_cell.h gh-117323: Make cell thread-safe in free-threaded builds (#117330) 2024-03-29 13:35:43 -04:00
pycore_ceval.h gh-110693: Pending Calls Machinery Cleanups (gh-118296) 2024-04-26 01:05:51 +00:00
pycore_ceval_state.h gh-110693: Use a Larger Queue for Per-Interpreter Pending Calls (gh-118302) 2024-04-26 19:13:44 -06:00
pycore_code.h Remove more remnants of deepfreeze (#118159) 2024-04-22 12:17:57 -07:00
pycore_codecs.h gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221) 2023-08-21 19:15:52 +02:00
pycore_compile.h gh-117494: extract the Instruction Sequence data structure into a separate file (#117496) 2024-04-04 15:47:26 +00:00
pycore_complexobject.h gh-112026: Restore removed private C API (#112115) 2023-11-15 16:38:31 +00:00
pycore_condvar.h gh-104530: Enable native Win32 condition variables by default (GH-104531) 2024-02-02 13:50:51 +00:00
pycore_context.h gh-111968: Refactor _PyXXX_Fini to integrate with _PyObject_ClearFreeLists (gh-114899) 2024-02-10 00:57:04 +00:00
pycore_critical_section.h gh-116664: Make module state Py_SETREF's in _warnings thread-safe (#116959) 2024-03-28 15:05:08 +00:00
pycore_crossinterp.h gh-76785: Handle Legacy Interpreters Properly (gh-117490) 2024-04-11 23:23:25 +00:00
pycore_descrobject.h gh-106320: Move _PyMethodWrapper_Type to internal C API (#107064) 2023-07-22 20:57:59 +00:00
pycore_dict.h gh-112075: Make instance attributes stored in inline "dict" thread safe (#114742) 2024-04-21 22:57:05 -07:00
pycore_dict_state.h GH-113710: Add a "globals to constants" pass (GH-114592) 2024-02-02 12:14:34 +00:00
pycore_dtoa.h gh-111962: Make dtoa thread-safe in --disable-gil builds. (#112049) 2023-12-07 13:47:55 +00:00
pycore_emscripten_signal.h GH-108614: Unbreak emscripten build (GH-109132) 2023-09-08 17:54:45 +01:00
pycore_emscripten_trampoline.h gh-106213: Make Emscripten trampolines work with JSPI (GH-106219) 2023-09-15 15:04:21 -07:00
pycore_exceptions.h
pycore_faulthandler.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_fileutils.h gh-102511: Speed up os.path.splitroot() with native helpers (GH-118089) 2024-04-25 10:07:38 +01:00
pycore_fileutils_windows.h gh-108220: Internal header files require Py_BUILD_CORE to be defined (#108221) 2023-08-21 19:15:52 +02:00
pycore_floatobject.h GH-115802: JIT "small" code for Windows (GH-115964) 2024-02-29 08:11:28 -08:00
pycore_flowgraph.h gh-117494: extract the Instruction Sequence data structure into a separate file (#117496) 2024-04-04 15:47:26 +00:00
pycore_format.h
pycore_frame.h GH-118095: Handle RETURN_GENERATOR in tier 2 (GH-118180) 2024-04-25 11:32:47 +01:00
pycore_freelist.h gh-111968: Split _Py_async_gen_asend_freelist out of _Py_async_gen_fr… (gh-115546) 2024-02-17 10:03:10 +09:00
pycore_function.h gh-117045: Add code object to function version cache (#117028) 2024-03-21 12:37:41 -07:00
pycore_gc.h gh-116818: Make sys.settrace, sys.setprofile, and monitoring thread-safe (#116775) 2024-04-19 14:47:42 -07:00
pycore_genobject.h GH-115802: JIT "small" code for Windows (GH-115964) 2024-02-29 08:11:28 -08:00
pycore_getopt.h
pycore_gil.h gh-116167: Allow disabling the GIL with PYTHON_GIL=0 or -X gil=0 (#116338) 2024-03-11 11:02:58 -04:00
pycore_global_objects.h gh-108216: Cleanup #include in internal header files (#108228) 2023-08-21 18:05:59 +00:00
pycore_global_objects_fini_generated.h gh-95754: Better error when script shadows a standard library or third party module (#113769) 2024-04-22 18:24:21 -07:00
pycore_global_strings.h gh-95754: Better error when script shadows a standard library or third party module (#113769) 2024-04-22 18:24:21 -07:00
pycore_hamt.h
pycore_hashtable.h gh-107211: No longer export internal functions (5) (#108423) 2023-08-24 16:06:53 +00:00
pycore_identifier.h gh-112026: Restore removed private C API (#112115) 2023-11-15 16:38:31 +00:00
pycore_import.h gh-117953: Split Up _PyImport_LoadDynamicModuleWithSpec() (gh-118203) 2024-04-29 09:29:07 -06:00
pycore_importdl.h gh-117953: Split Up _PyImport_LoadDynamicModuleWithSpec() (gh-118203) 2024-04-29 09:29:07 -06:00
pycore_initconfig.h gh-116167: Allow disabling the GIL with PYTHON_GIL=0 or -X gil=0 (#116338) 2024-03-11 11:02:58 -04:00
pycore_instruction_sequence.h gh-117901: Add option for compiler's codegen to save nested instruction sequences for introspection (#118007) 2024-04-24 09:46:17 +00:00
pycore_instruments.h chore: fix typos (#116345) 2024-03-05 09:05:52 -07:00
pycore_interp.h gh-76785: Handle Legacy Interpreters Properly (gh-117490) 2024-04-11 23:23:25 +00:00
pycore_intrinsics.h GH-115802: JIT "small" code for Windows (GH-115964) 2024-02-29 08:11:28 -08:00
pycore_jit.h GH-112354: Initial implementation of warm up on exits and trace-stitching (GH-114142) 2024-02-20 09:39:55 +00:00
pycore_list.h gh-116381: Remove bad specializations, add fail stats (GH-116464) 2024-03-08 00:21:21 +08:00
pycore_llist.h gh-111964: Implement stop-the-world pauses (gh-112471) 2024-01-23 11:08:23 -07:00
pycore_lock.h gh-114271: Fix race in Thread.join() (#114839) 2024-03-16 13:56:30 +01:00
pycore_long.h GH-115802: JIT "small" code for Windows (GH-115964) 2024-02-29 08:11:28 -08:00
pycore_memoryobject.h gh-106320: Remove private _PyManagedBuffer_Type (#108431) 2023-08-24 19:07:54 +02:00
pycore_mimalloc.h gh-112536: Define MI_TSAN to 1 for --with-mimalloc and --with-thread-sanitizer (gh-116558) 2024-03-11 22:25:55 +09:00
pycore_modsupport.h gh-111956: Add thread-safe one-time initialization. (gh-111960) 2023-11-16 12:19:54 -07:00
pycore_moduleobject.h gh-106320: Remove private _PyModule API (#107070) 2023-07-22 21:41:11 +00:00
pycore_namespace.h gh-107211: No longer export internal functions (4) (#107217) 2023-07-25 03:16:28 +00:00
pycore_object.h gh-117657: Fixes a few small TSAN issues in dictobject (#118200) 2024-04-25 08:53:29 -07:00
pycore_object_alloc.h gh-112529: Use GC heaps for GC allocations in free-threaded builds (gh-114157) 2024-01-21 01:14:45 +09:00
pycore_object_stack.h gh-111968: Refactor _PyXXX_Fini to integrate with _PyObject_ClearFreeLists (gh-114899) 2024-02-10 00:57:04 +00:00
pycore_object_state.h gh-111968: Rename freelist related struct names to Eric's suggestion (gh-115329) 2024-02-14 00:32:51 +00:00
pycore_obmalloc.h gh-113055: Use pointer for interp->obmalloc state (gh-113412) 2024-01-26 19:38:14 -08:00
pycore_obmalloc_init.h gh-113055: Use pointer for interp->obmalloc state (gh-113412) 2024-01-26 19:38:14 -08:00
pycore_opcode_metadata.h GH-118095: Add dynamic exit support and FOR_ITER_GEN support to tier 2 (GH-118279) 2024-04-26 18:08:50 +01:00
pycore_opcode_utils.h gh-111354: simplify detection of RESUME after YIELD_VALUE at except-depth 1 (#111459) 2023-11-02 10:18:43 +00:00
pycore_optimizer.h GH-115480: Reduce guard strength for binary ops when type of one operand is known already (GH-118050) 2024-04-22 13:34:06 +01:00
pycore_parking_lot.h gh-110850: Cleanup pycore_time.h includes (#115724) 2024-02-20 16:50:43 +00:00
pycore_parser.h gh-110805: Allow the repl to show source code and complete tracebacks (#110775) 2023-10-13 09:25:37 +00:00
pycore_pathconfig.h gh-107211: No longer export internal functions (6) (#108424) 2023-08-24 17:28:35 +02:00
pycore_pyarena.h gh-107211: Fix test_peg_generator (#108435) 2023-08-24 17:47:44 +00:00
pycore_pyatomic_ft_wrappers.h gh-112075: Make instance attributes stored in inline "dict" thread safe (#114742) 2024-04-21 22:57:05 -07:00
pycore_pybuffer.h gh-76785: Rename _xxsubinterpreters to _interpreters (gh-117791) 2024-04-24 16:18:24 +00:00
pycore_pyerrors.h gh-116809: Restore removed _PyErr_ChainExceptions1() function (#116900) 2024-03-16 21:37:11 +01:00
pycore_pyhash.h gh-111545: Add Py_HashPointer() function (#112096) 2023-12-06 15:09:22 +01:00
pycore_pylifecycle.h Remove more remnants of deepfreeze (#118159) 2024-04-22 12:17:57 -07:00
pycore_pymath.h
pycore_pymem.h gh-112075: Support freeing object memory via QSBR (#116344) 2024-03-08 09:56:36 -08:00
pycore_pymem_init.h gh-115103: Implement delayed free mechanism for free-threaded builds (#115367) 2024-02-20 13:04:37 -05:00
pycore_pystate.h gh-76785: Rename _xxsubinterpreters to _interpreters (gh-117791) 2024-04-24 16:18:24 +00:00
pycore_pystats.h gh-108753: Enhance pystats (#108754) 2023-09-06 15:54:59 +00:00
pycore_pythonrun.h gh-106320: Remove private pythonrun API (#108599) 2023-08-29 04:18:52 +02:00
pycore_pythread.h gh-76785: Rename _xxsubinterpreters to _interpreters (gh-117791) 2024-04-24 16:18:24 +00:00
pycore_qsbr.h gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435) 2024-03-06 09:42:11 -05:00
pycore_range.h
pycore_runtime.h gh-115773: Add tests to exercise the _Py_DebugOffsets structure (#115774) 2024-02-28 10:17:34 +00:00
pycore_runtime_init.h gh-110693: Pending Calls Machinery Cleanups (gh-118296) 2024-04-26 01:05:51 +00:00
pycore_runtime_init_generated.h gh-95754: Better error when script shadows a standard library or third party module (#113769) 2024-04-22 18:24:21 -07:00
pycore_semaphore.h gh-110850: Cleanup pycore_time.h includes (#115724) 2024-02-20 16:50:43 +00:00
pycore_setobject.h gh-112069: Add _PySet_NextEntryRef to be thread-safe. (gh-117990) 2024-04-19 00:18:22 +09:00
pycore_signal.h gh-109693: Use pyatomic.h for signal module (gh-110480) 2023-10-10 08:26:29 +09:00
pycore_sliceobject.h GH-115802: JIT "small" code for Windows (GH-115964) 2024-02-29 08:11:28 -08:00
pycore_strhex.h gh-107211: No longer export pycore_strhex.h functions (#108229) 2023-08-21 18:12:22 +00:00
pycore_structseq.h gh-107211: No longer export internal functions (4) (#107217) 2023-07-25 03:16:28 +00:00
pycore_symtable.h gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private (#117412) 2024-04-02 10:34:49 +00:00
pycore_sysmodule.h gh-106320: Remove private _PySys functions (#108452) 2023-08-24 20:02:09 +00:00
pycore_time.h gh-110850: Fix _PyTime_FromSecondsDouble() API (#116606) 2024-03-11 16:35:29 +00:00
pycore_token.h gh-107211: No longer export internal functions (7) (#108425) 2023-08-24 17:40:56 +02:00
pycore_traceback.h gh-110721: Use the traceback module for PyErr_Display() and fallback to the C implementation (#110702) 2023-10-12 14:52:14 +00:00
pycore_tracemalloc.h gh-107211: No longer export internal functions (3) (#107215) 2023-07-25 02:25:45 +00:00
pycore_tstate.h gh-117439: Make refleak checking thread-safe without the GIL (#117469) 2024-04-08 12:11:36 -04:00
pycore_tuple.h gh-116381: Remove bad specializations, add fail stats (GH-116464) 2024-03-08 00:21:21 +08:00
pycore_typeobject.h gh-117578: Introduce _PyType_GetModuleByDef2 private function (GH-117661) 2024-04-25 13:51:31 +02:00
pycore_typevarobject.h
pycore_ucnhash.h gh-111972: Make Unicode name C APIcapsule initialization thread-safe (#112249) 2023-11-30 11:12:49 +01:00
pycore_unicodeobject.h GH-115802: JIT "small" code for Windows (GH-115964) 2024-02-29 08:11:28 -08:00
pycore_unicodeobject_generated.h gh-95754: Better error when script shadows a standard library or third party module (#113769) 2024-04-22 18:24:21 -07:00
pycore_unionobject.h gh-105858: Expose some union-related objects as internal APIs (GH-116025) 2024-02-28 09:56:40 +00:00
pycore_uop_ids.h GH-118095: Allow a variant of RESUME_CHECK in tier 2 (GH-118286) 2024-04-29 07:54:05 +01:00
pycore_uop_metadata.h GH-118095: Allow a variant of RESUME_CHECK in tier 2 (GH-118286) 2024-04-29 07:54:05 +01:00
pycore_warnings.h gh-116664: Make module state Py_SETREF's in _warnings thread-safe (#116959) 2024-03-28 15:05:08 +00:00
pycore_weakref.h gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168) 2024-04-08 10:58:38 -04:00