[issue38721] modulefinder should use import hooks properly

Brandt Bucher report at bugs.python.org
Thu Nov 21 15:42:01 EST 2019


Brandt Bucher <brandtbucher at gmail.com> added the comment:

I'm not sure what you mean when you say "modulefinder currently will detect modules imported by a script dynamically by running the script"... modulefinder is completely static, no?

I also think that changing sys.path like this is a bad idea (I tried this in an earlier PR and was told to remove it and rework my solution). We lose thread-safety, and it has effects far outside of the scope of modulefinder (i.e. the hooks we call could cache it or something, and break later imports). If changing sys.path is the only way to accomplish this (still not exactly sure what), I doubt it will be accepted. It seems like this PR does a lot of unnecessary refactoring too, on first glance.

With that said, adding support for hooks should be fairly straightforward by just manually walking down sys.path/meta_path/path_hooks in _find_module... maybe.

----------
nosy: +brandtbucher

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38721>
_______________________________________


More information about the Python-bugs-list mailing list