bpo-42955: Remove sub-packages from sys.stdlib_module_names (GH-24353)

This commit is contained in:
Victor Stinner 2021-01-28 00:03:23 +01:00 committed by GitHub
parent c9b8e9c421
commit 64fc105b2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 34 deletions

View file

@ -57,29 +57,17 @@ def list_python_modules(names):
names.add(name)
def _list_sub_packages(path, names, parent=None):
for name in os.listdir(path):
# Packages in Lib/
def list_packages(names):
for name in os.listdir(STDLIB_PATH):
if name in IGNORE:
continue
package_path = os.path.join(path, name)
package_path = os.path.join(STDLIB_PATH, name)
if not os.path.isdir(package_path):
continue
if not any(package_file.endswith(".py")
for package_file in os.listdir(package_path)):
continue
if parent:
qualname = f"{parent}.{name}"
else:
qualname = name
if qualname in IGNORE:
continue
names.add(qualname)
_list_sub_packages(package_path, names, qualname)
# Packages and sub-packages
def list_packages(names):
_list_sub_packages(STDLIB_PATH, names)
if any(package_file.endswith(".py")
for package_file in os.listdir(package_path)):
names.add(name)
# Extension modules built by setup.py