On Mon, Jan 25, 2021 at 11:22 PM Ivan Pozdeev via Python-Dev
<[email protected]> wrote:
That's not possible.
Stdlib can be arranged any way a user/maintainer wishes (zipped stdlib and virtual
environments are just two examples), so there's no way to tell if the module's location
is "right".
Dowstream changes are also standard practice so there's no way to verify a
module's contents, either.
As such, there's no way to tell if any given module being imported is a
standard or a 3rd-party one.
By the way, IMO it's also a legit use case on an old Python version to
override a stdlib module with a patched or more recent version, to get
a bugfix for example ;-) Even if it's an uncommon use case, it can
solve some practical issues.
Victor