bpo-45189: Drop the "list_frozen" command from _test_embed. (GH-30273)

This commit is contained in:
Dong-hee Na 2021-12-28 11:05:50 +09:00 committed by GitHub
parent 3581c7abbe
commit 196b53eb1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 32 deletions

View file

@ -1827,26 +1827,6 @@ static int test_frozenmain(void)
}
#endif // !MS_WINDOWS
// List frozen modules.
// Command used by Tools/scripts/generate_stdlib_module_names.py script.
static int list_frozen(void)
{
const struct _frozen *p;
for (p = _PyImport_FrozenBootstrap; ; p++) {
if (p->name == NULL)
break;
printf("%s\n", p->name);
}
for (p = _PyImport_FrozenStdlib; ; p++) {
if (p->name == NULL)
break;
printf("%s\n", p->name);
}
return 0;
}
static int test_repeated_init_and_inittab(void)
{
// bpo-44441: Py_RunMain() must reset PyImport_Inittab at exit.
@ -1960,8 +1940,6 @@ static struct TestCase TestCases[] = {
{"test_frozenmain", test_frozenmain},
#endif
// Command
{"list_frozen", list_frozen},
{NULL, NULL}
};

View file

@ -1,5 +1,6 @@
# This script lists the names of standard library modules
# to update Python/stdlib_mod_names.h
import _imp
import os.path
import re
import subprocess
@ -11,7 +12,6 @@
STDLIB_PATH = os.path.join(SRC_DIR, 'Lib')
MODULES_SETUP = os.path.join(SRC_DIR, 'Modules', 'Setup')
SETUP_PY = os.path.join(SRC_DIR, 'setup.py')
TEST_EMBED = os.path.join(SRC_DIR, 'Programs', '_testembed')
IGNORE = {
'__init__',
@ -117,16 +117,11 @@ def list_modules_setup_extensions(names):
# List frozen modules of the PyImport_FrozenModules list (Python/frozen.c).
# Use the "./Programs/_testembed list_frozen" command.
def list_frozen(names):
args = [TEST_EMBED, 'list_frozen']
proc = subprocess.run(args, stdout=subprocess.PIPE, text=True)
exitcode = proc.returncode
if exitcode:
cmd = ' '.join(args)
print(f"{cmd} failed with exitcode {exitcode}")
sys.exit(exitcode)
submodules = set()
for line in proc.stdout.splitlines():
name = line.strip()
for name in _imp._frozen_module_names():
# To skip __hello__, __hello_alias__ and etc.
if name.startswith('__'):
continue
if '.' in name:
submodules.add(name)
else: