bpo-43445: Add frozen modules to sys.stdlib_module_names (GH-24798) · python/cpython@307745a · GitHub
Skip to content

Commit 307745a

Browse files
authored
bpo-43445: Add frozen modules to sys.stdlib_module_names (GH-24798)
Add frozen modules to sys.stdlib_module_names. For example, add "_frozen_importlib" and "_frozen_importlib_external" names. Add "list_frozen" command to Programs/_testembed.
1 parent b4f9089 commit 307745a

5 files changed

Lines changed: 53 additions & 4 deletions

File tree

Makefile.pre.in

Lines changed: 1 addition & 1 deletion
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add frozen modules to :data:`sys.stdlib_module_names`. For example, add
2+
``"_frozen_importlib"`` and ``"_frozen_importlib_external"`` names.

Programs/_testembed.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,20 @@ static int test_unicode_id_init(void)
17211721
}
17221722

17231723

1724+
// List frozen modules.
1725+
// Command used by Tools/scripts/generate_stdlib_module_names.py script.
1726+
static int list_frozen(void)
1727+
{
1728+
const struct _frozen *p;
1729+
for (p = PyImport_FrozenModules; ; p++) {
1730+
if (p->name == NULL)
1731+
break;
1732+
printf("%s\n", p->name);
1733+
}
1734+
return 0;
1735+
}
1736+
1737+
17241738

17251739
/* *********************************************************
17261740
* List of test cases and the function that implements it.
@@ -1792,6 +1806,8 @@ static struct TestCase TestCases[] = {
17921806
{"test_audit_run_stdin", test_audit_run_stdin},
17931807

17941808
{"test_unicode_id_init", test_unicode_id_init},
1809+
1810+
{"list_frozen", list_frozen},
17951811
{NULL, NULL}
17961812
};
17971813

Python/stdlib_module_names.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ static const char* _Py_stdlib_module_names[] = {
3232
"_dbm",
3333
"_decimal",
3434
"_elementtree",
35+
"_frozen_importlib",
36+
"_frozen_importlib_external",
3537
"_functools",
3638
"_gdbm",
3739
"_hashlib",

Tools/scripts/generate_stdlib_module_names.py

Lines changed: 32 additions & 3 deletions

0 commit comments

Comments
 (0)