Ronald Oussoren <ronaldousso...@mac.com> added the comment:

>> Wouldn't it be sufficient to somehow mark the stdlib entries on sys.path? 
>> Although that might give misleading answers with tools like 
>> pyinstaller/py2exe/py2app that package an application and its dependencies 
>> into a single zipfile.

> Having to actually import modules to check if it's a stdlib module or not is 
> not convenient. Many stdlib modules have side effects on import. For example, 
> "import antigravity" opens a web browser. An import can open files, spawn 
> threads, run programs, etc.

You wouldn't necessarily have to import a module to test, this is something 
that could be added to importlib.  One (poorly thought out) option is to add 
sys._stdlib_path with the subsection of sys.path that contains the stdlib, and 
a function in importlib that returns if a spec is for a stdlib module.

The disadvantage of this, or for the most part anything but your initial 
proposal, is that might not be save to use a function in importlib in 
Py_FatalError.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42955>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to