File tree 2 files changed +5
-32
lines changed
2 files changed +5
-32
lines changed Original file line number Diff line number Diff line change @@ -1827,26 +1827,6 @@ static int test_frozenmain(void)
1827
1827
}
1828
1828
#endif // !MS_WINDOWS
1829
1829
1830
-
1831
- // List frozen modules.
1832
- // Command used by Tools/scripts/generate_stdlib_module_names.py script.
1833
- static int list_frozen (void )
1834
- {
1835
- const struct _frozen * p ;
1836
- for (p = _PyImport_FrozenBootstrap ; ; p ++ ) {
1837
- if (p -> name == NULL )
1838
- break ;
1839
- printf ("%s\n" , p -> name );
1840
- }
1841
- for (p = _PyImport_FrozenStdlib ; ; p ++ ) {
1842
- if (p -> name == NULL )
1843
- break ;
1844
- printf ("%s\n" , p -> name );
1845
- }
1846
- return 0 ;
1847
- }
1848
-
1849
-
1850
1830
static int test_repeated_init_and_inittab (void )
1851
1831
{
1852
1832
// bpo-44441: Py_RunMain() must reset PyImport_Inittab at exit.
@@ -1960,8 +1940,6 @@ static struct TestCase TestCases[] = {
1960
1940
{"test_frozenmain" , test_frozenmain },
1961
1941
#endif
1962
1942
1963
- // Command
1964
- {"list_frozen" , list_frozen },
1965
1943
{NULL , NULL }
1966
1944
};
1967
1945
Original file line number Diff line number Diff line change 1
1
# This script lists the names of standard library modules
2
2
# to update Python/stdlib_mod_names.h
3
+ import _imp
3
4
import os .path
4
5
import re
5
6
import subprocess
11
12
STDLIB_PATH = os .path .join (SRC_DIR , 'Lib' )
12
13
MODULES_SETUP = os .path .join (SRC_DIR , 'Modules' , 'Setup' )
13
14
SETUP_PY = os .path .join (SRC_DIR , 'setup.py' )
14
- TEST_EMBED = os .path .join (SRC_DIR , 'Programs' , '_testembed' )
15
15
16
16
IGNORE = {
17
17
'__init__' ,
@@ -117,16 +117,11 @@ def list_modules_setup_extensions(names):
117
117
# List frozen modules of the PyImport_FrozenModules list (Python/frozen.c).
118
118
# Use the "./Programs/_testembed list_frozen" command.
119
119
def list_frozen (names ):
120
- args = [TEST_EMBED , 'list_frozen' ]
121
- proc = subprocess .run (args , stdout = subprocess .PIPE , text = True )
122
- exitcode = proc .returncode
123
- if exitcode :
124
- cmd = ' ' .join (args )
125
- print (f"{ cmd } failed with exitcode { exitcode } " )
126
- sys .exit (exitcode )
127
120
submodules = set ()
128
- for line in proc .stdout .splitlines ():
129
- name = line .strip ()
121
+ for name in _imp ._frozen_module_names ():
122
+ # To skip __hello__, __hello_alias__ and etc.
123
+ if name .startswith ('__' ):
124
+ continue
130
125
if '.' in name :
131
126
submodules .add (name )
132
127
else :
You can’t perform that action at this time.
0 commit comments