On Mon, 25 Jan 2021 23:05:07 +0100 Victor Stinner <vstinner@python.org> wrote:
This is a different use case which requires a different solution. sys.module_names solve some specific use cases (that I listed in my first email).
In Python 3.9, you can already check if a module __file__ is in the sysconfig.get_paths()['stdlib'] directory. You don't need to modify Python for that.
Is this reliable? What if the stdlib is zipped or frozen in some way?
If you also would like to check if an *extension* module comes from the stdlib, you need to get the "lib-dynload" directory.
So you're saying the need is already fulfilled, even though it only has a cryptic (*) and partial solution? (*) who would think about `sysconfig.get_paths()['stdlib']` on their own? Regards Antoine.