Author martin.panter
Recipients martin.panter
Date 2015-11-02.11:14:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When no specific list of paths are given, pkgutil.iter_modules() and walk_packages() will list modules found on sys.path. But they don’t list built-in modules, which don’t live in a particular directory. So many users of these APIs (such as the ModuleScanner class in pydoc) have to separately iterate over sys.builtin_module_names.

I think it would be good to change the pkgutil module to also yield the builtin modules. Attached is a patch which does this.

However I had second thoughts on blindly changing the existing function to yield the extra modules, because this will hurt backward compatibility for people already working around the problem. For example, if I didn’t also update pydoc in my patch, a module search would list the built-in modules twice. Perhaps we could overcome this with an opt-in flag like iter_modules(builtins=True)? I’m interested if anyone else has an opinion on this.

Adding support for builtins could also help with proposals such as listing the entire library (Issue 20506) and autocompletion of module names (Issue 25419).
Date User Action Args
2015-11-02 11:14:13martin.pantersetrecipients: + martin.panter
2015-11-02 11:14:13martin.pantersetmessageid: <>
2015-11-02 11:14:13martin.panterlinkissue25533 messages
2015-11-02 11:14:12martin.pantercreate