@@ -56,35 +56,37 @@ class struct_frozen(Structure):
56
56
("size" , c_int )]
57
57
FrozenTable = POINTER (struct_frozen )
58
58
59
- ft = FrozenTable .in_dll (pythonapi , "PyImport_FrozenModules" )
60
- # ft is a pointer to the struct_frozen entries:
61
59
modules = []
62
- for entry in ft :
63
- # This is dangerous. We *can* iterate over a pointer, but
64
- # the loop will not terminate (maybe with an access
65
- # violation;-) because the pointer instance has no size.
66
- if entry .name is None :
67
- break
68
- modname = entry .name .decode ("ascii" )
69
- modules .append (modname )
70
- with self .subTest (modname ):
71
- # Do a sanity check on entry.size and entry.code.
72
- self .assertGreater (abs (entry .size ), 10 )
73
- self .assertTrue ([entry .code [i ] for i in range (abs (entry .size ))])
74
- # Check the module's package-ness.
75
- with import_helper .frozen_modules ():
76
- spec = importlib .util .find_spec (modname )
77
- if entry .size < 0 :
78
- # It's a package.
79
- self .assertIsNotNone (spec .submodule_search_locations )
80
- else :
81
- self .assertIsNone (spec .submodule_search_locations )
60
+ for group in ["Bootstrap" , "Stdlib" , "Test" ]:
61
+ ft = FrozenTable .in_dll (pythonapi , f"_PyImport_Frozen{ group } " )
62
+ # ft is a pointer to the struct_frozen entries:
63
+ for entry in ft :
64
+ # This is dangerous. We *can* iterate over a pointer, but
65
+ # the loop will not terminate (maybe with an access
66
+ # violation;-) because the pointer instance has no size.
67
+ if entry .name is None :
68
+ break
69
+ modname = entry .name .decode ("ascii" )
70
+ modules .append (modname )
71
+ with self .subTest (modname ):
72
+ # Do a sanity check on entry.size and entry.code.
73
+ self .assertGreater (abs (entry .size ), 10 )
74
+ self .assertTrue ([entry .code [i ] for i in range (abs (entry .size ))])
75
+ # Check the module's package-ness.
76
+ with import_helper .frozen_modules ():
77
+ spec = importlib .util .find_spec (modname )
78
+ if entry .size < 0 :
79
+ # It's a package.
80
+ self .assertIsNotNone (spec .submodule_search_locations )
81
+ else :
82
+ self .assertIsNone (spec .submodule_search_locations )
82
83
83
84
with import_helper .frozen_modules ():
84
85
expected = _imp ._frozen_module_names ()
85
86
self .maxDiff = None
86
- self .assertEqual (modules , expected , "PyImport_FrozenModules example "
87
- "in Doc/library/ctypes.rst may be out of date" )
87
+ self .assertEqual (modules , expected ,
88
+ "_PyImport_FrozenBootstrap example "
89
+ "in Doc/library/ctypes.rst may be out of date" )
88
90
89
91
from ctypes import _pointer_type_cache
90
92
del _pointer_type_cache [struct_frozen ]
0 commit comments