@@ -632,44 +632,45 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp)
632
632
633
633
(6). first time (not found in _PyRuntime.imports.extensions):
634
634
A. _imp_create_dynamic_impl() -> import_find_extension()
635
- B. _imp_create_dynamic_impl() -> _PyImport_LoadDynamicModuleWithSpec()
636
- C. _PyImport_LoadDynamicModuleWithSpec(): load <module init func>
637
- D. _PyImport_LoadDynamicModuleWithSpec(): call <module init func>
638
- E. <module init func> -> PyModule_Create() -> PyModule_Create2()
635
+ B. _imp_create_dynamic_impl() -> _PyImport_GetModInitFunc()
636
+ C. _PyImport_GetModInitFunc(): load <module init func>
637
+ D. _imp_create_dynamic_impl() -> _PyImport_RunModInitFunc()
638
+ E. _PyImport_RunModInitFunc(): call <module init func>
639
+ F. <module init func> -> PyModule_Create() -> PyModule_Create2()
639
640
-> PyModule_CreateInitialized()
640
- F. PyModule_CreateInitialized() -> PyModule_New()
641
- G. PyModule_CreateInitialized(): allocate mod->md_state
642
- H. PyModule_CreateInitialized() -> PyModule_AddFunctions()
643
- I. PyModule_CreateInitialized() -> PyModule_SetDocString()
644
- J. PyModule_CreateInitialized(): set mod->md_def
645
- K. <module init func>: initialize the module, etc.
646
- L. _PyImport_LoadDynamicModuleWithSpec()
647
- -> _PyImport_CheckSubinterpIncompatibleExtensionAllowed()
648
- M. _PyImport_LoadDynamicModuleWithSpec(): set def->m_base.m_init
649
- N. _PyImport_LoadDynamicModuleWithSpec() -> _PyImport_FixupExtensionObject()
650
- O. _PyImport_FixupExtensionObject() -> update_global_state_for_extension()
651
- P. update_global_state_for_extension():
652
- copy __dict__ into def->m_base.m_copy
653
- Q. update_global_state_for_extension():
654
- add it to _PyRuntime.imports.extensions
655
- R. _PyImport_FixupExtensionObject() -> finish_singlephase_extension()
656
- S. finish_singlephase_extension():
657
- add it to interp->imports.modules_by_index
658
- T. finish_singlephase_extension(): add it to sys.modules
659
- U. _imp_create_dynamic_impl(): set __file__
660
-
661
- Step (P) is skipped for core modules (sys/builtins).
641
+ G. PyModule_CreateInitialized() -> PyModule_New()
642
+ H. PyModule_CreateInitialized(): allocate mod->md_state
643
+ I. PyModule_CreateInitialized() -> PyModule_AddFunctions()
644
+ J. PyModule_CreateInitialized() -> PyModule_SetDocString()
645
+ K. PyModule_CreateInitialized(): set mod->md_def
646
+ L. <module init func>: initialize the module, etc.
647
+ M. _PyImport_RunModInitFunc(): set def->m_base.m_init
648
+ N. _imp_create_dynamic_impl()
649
+ -> _PyImport_CheckSubinterpIncompatibleExtensionAllowed()
650
+ O. _imp_create_dynamic_impl(): set __file__
651
+ P. _imp_create_dynamic_impl() -> update_global_state_for_extension()
652
+ Q. update_global_state_for_extension():
653
+ copy __dict__ into def->m_base.m_copy
654
+ R. update_global_state_for_extension():
655
+ add it to _PyRuntime.imports.extensions
656
+ S. _imp_create_dynamic_impl() -> finish_singlephase_extension()
657
+ T. finish_singlephase_extension():
658
+ add it to interp->imports.modules_by_index
659
+ U. finish_singlephase_extension(): add it to sys.modules
660
+
661
+ Step (Q) is skipped for core modules (sys/builtins).
662
662
663
663
(6). subsequent times (found in _PyRuntime.imports.extensions):
664
664
A. _imp_create_dynamic_impl() -> import_find_extension()
665
- B. import_find_extension() -> import_add_module()
666
- C. if name in sys.modules: use that module
667
- D. else:
665
+ B. import_find_extension()
666
+ -> _PyImport_CheckSubinterpIncompatibleExtensionAllowed()
667
+ C. import_find_extension() -> import_add_module()
668
+ D. if name in sys.modules: use that module
669
+ E. else:
668
670
1. import_add_module() -> PyModule_NewObject()
669
671
2. import_add_module(): set it on sys.modules
670
- E. import_find_extension(): copy the "m_copy" dict into __dict__
671
- F. _imp_create_dynamic_impl()
672
- -> _PyImport_CheckSubinterpIncompatibleExtensionAllowed()
672
+ F. import_find_extension(): copy the "m_copy" dict into __dict__
673
+ G. import_find_extension(): add to modules_by_index
673
674
674
675
(10). (every time):
675
676
A. noop
@@ -678,19 +679,22 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp)
678
679
...for single-phase init modules, where m_size >= 0:
679
680
680
681
(6). not main interpreter and never loaded there - every time (not found in _PyRuntime.imports.extensions):
681
- A-N . (same as for m_size == -1)
682
- O-Q . (skipped)
683
- R -U. (same as for m_size == -1)
682
+ A-O . (same as for m_size == -1)
683
+ P-R . (skipped)
684
+ S -U. (same as for m_size == -1)
684
685
685
686
(6). main interpreter - first time (not found in _PyRuntime.imports.extensions):
686
- A-O . (same as for m_size == -1)
687
- P . (skipped)
688
- Q -U. (same as for m_size == -1)
687
+ A-Q . (same as for m_size == -1)
688
+ R . (skipped)
689
+ S -U. (same as for m_size == -1)
689
690
690
- (6). previously loaded in main interpreter (found in _PyRuntime.imports.extensions):
691
+ (6). subsequent times (found in _PyRuntime.imports.extensions):
691
692
A. _imp_create_dynamic_impl() -> import_find_extension()
692
- B. import_find_extension(): call def->m_base.m_init
693
- C. import_find_extension(): add the module to sys.modules
693
+ B. import_find_extension()
694
+ -> _PyImport_CheckSubinterpIncompatibleExtensionAllowed()
695
+ C. import_find_extension(): call def->m_base.m_init (see above)
696
+ D. import_find_extension(): add the module to sys.modules
697
+ E. import_find_extension(): add to modules_by_index
694
698
695
699
(10). every time:
696
700
A. noop
0 commit comments