Skip to content

bpo-45189: Drop the "list_frozen" command from _test_embed. #30273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1960,8 +1940,6 @@ static struct TestCase TestCases[] = {
{"test_frozenmain", test_frozenmain},
#endif

// Command
{"list_frozen", list_frozen},
{NULL, NULL}
};

Expand Down
15 changes: 5 additions & 10 deletions Tools/scripts/generate_stdlib_module_names.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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__',
Expand Down Expand Up @@ -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']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since TEST_EMBED is not used anymore, line 15 (TEST_EMBED = os.path.join(SRC_DIR, 'Programs', '_testembed')) needs to be removed as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arhadthedev Thanks!

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:
Expand Down