Skip to content

Commit 196b53e

Browse files
authored
bpo-45189: Drop the "list_frozen" command from _test_embed. (GH-30273)
1 parent 3581c7a commit 196b53e

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

Programs/_testembed.c

-22
Original file line numberDiff line numberDiff line change
@@ -1827,26 +1827,6 @@ static int test_frozenmain(void)
18271827
}
18281828
#endif // !MS_WINDOWS
18291829

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-
18501830
static int test_repeated_init_and_inittab(void)
18511831
{
18521832
// bpo-44441: Py_RunMain() must reset PyImport_Inittab at exit.
@@ -1960,8 +1940,6 @@ static struct TestCase TestCases[] = {
19601940
{"test_frozenmain", test_frozenmain},
19611941
#endif
19621942

1963-
// Command
1964-
{"list_frozen", list_frozen},
19651943
{NULL, NULL}
19661944
};
19671945

Tools/scripts/generate_stdlib_module_names.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This script lists the names of standard library modules
22
# to update Python/stdlib_mod_names.h
3+
import _imp
34
import os.path
45
import re
56
import subprocess
@@ -11,7 +12,6 @@
1112
STDLIB_PATH = os.path.join(SRC_DIR, 'Lib')
1213
MODULES_SETUP = os.path.join(SRC_DIR, 'Modules', 'Setup')
1314
SETUP_PY = os.path.join(SRC_DIR, 'setup.py')
14-
TEST_EMBED = os.path.join(SRC_DIR, 'Programs', '_testembed')
1515

1616
IGNORE = {
1717
'__init__',
@@ -117,16 +117,11 @@ def list_modules_setup_extensions(names):
117117
# List frozen modules of the PyImport_FrozenModules list (Python/frozen.c).
118118
# Use the "./Programs/_testembed list_frozen" command.
119119
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)
127120
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
130125
if '.' in name:
131126
submodules.add(name)
132127
else:

0 commit comments

Comments
 (0)