summaryrefslogtreecommitdiffstats
path: root/Tools/build
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-06-20 08:12:44 (GMT)
committerGitHub <noreply@github.com>2023-06-20 08:12:44 (GMT)
commit155577de1b6a7f4404b2bf90bcc1a588201550da (patch)
tree053bdb04a5d6ee7f6ff3c9d972f20c3149aef790 /Tools/build
parentcb388c9a85a8dd6817ea7d969f53657002df6272 (diff)
downloadcpython-155577de1b6a7f4404b2bf90bcc1a588201550da.zip
cpython-155577de1b6a7f4404b2bf90bcc1a588201550da.tar.gz
cpython-155577de1b6a7f4404b2bf90bcc1a588201550da.tar.bz2
make regen-stdlib-module-names rejects test modules (#105921)
Make sure that sys.stdlib_module_names doesn't contain test modules.
Diffstat (limited to 'Tools/build')
-rw-r--r--Tools/build/generate_stdlib_module_names.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/Tools/build/generate_stdlib_module_names.py b/Tools/build/generate_stdlib_module_names.py
index 17668f4..72f6923 100644
--- a/Tools/build/generate_stdlib_module_names.py
+++ b/Tools/build/generate_stdlib_module_names.py
@@ -43,6 +43,16 @@ IGNORE = {
'xxsubtype',
}
+ALLOW_TEST_MODULES = {
+ 'doctest',
+ 'unittest',
+}
+
+# Built-in modules
+def list_builtin_modules(names):
+ names |= set(sys.builtin_module_names)
+
+
# Pure Python modules (Lib/*.py)
def list_python_modules(names):
for filename in os.listdir(STDLIB_PATH):
@@ -93,7 +103,9 @@ def list_frozen(names):
def list_modules():
- names = set(sys.builtin_module_names)
+ names = set()
+
+ list_builtin_modules(names)
list_modules_setup_extensions(names)
list_packages(names)
list_python_modules(names)
@@ -106,9 +118,12 @@ def list_modules():
if package_name in IGNORE:
names.discard(name)
+ # Sanity checks
for name in names:
if "." in name:
- raise Exception("sub-modules must not be listed")
+ raise Exception(f"sub-modules must not be listed: {name}")
+ if ("test" in name or "xx" in name) and name not in ALLOW_TEST_MODULES:
+ raise Exception(f"test modules must not be listed: {name}")
return names