Skip to content

Commit 8d07bf0

Browse files
committed
importlib: Add iter_modules support to BuiltinLoader
1 parent dd0b593 commit 8d07bf0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/importlib/_bootstrap.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,13 @@ def is_package(cls, fullname):
798798
"""Return False as built-in modules are never packages."""
799799
return False
800800

801+
@classmethod
802+
def iter_modules(cls, prefix=''):
803+
"""Yield all built-in modules matching the given prefix."""
804+
for name in sys.builtin_module_names:
805+
if name.startswith(prefix):
806+
yield name, False
807+
801808
load_module = classmethod(_load_module_shim)
802809

803810

0 commit comments

Comments
 (0)