Issue 35936: Give modulefinder some much-needed updates. (original) (raw)
I've written a patch here that includes a few useful fixes. Namely:
- It doesn't crash if it encounters a syntax error. (17396)
- It doesn't report certain name collisions as bad. (35376)
- It doesn't use mutable default arguments in its initializer.
- Most importantly, it now uses
importlib
instead ofimp
, which is deprecated. (25160) As a benefit, frozen built-in modules (zip import
, for example), are now correctly reported.
With the exception of these bug fixes, I've been very careful to preserve the original behavior, and have not changed any part of the API. This patch also includes 2 new regression tests.
Alright, I've gotten all of the tests passing for the new importlib-only implementation. I broke these modifications out into a new private function, _find_module, to make it clear that this fix is a simple drop-in replacement for imp.find_module.
Let me know if there's anything I've missed or could improve. Otherwise, I feel my work here is done!