[issue26131] Raise ImportWarning when loader.load_module() is used

Brett Cannon report at bugs.python.org
Fri Aug 9 12:50:43 EDT 2019


Brett Cannon <brett at python.org> added the comment:

If you look at https://github.com/python/cpython/blob/master/Lib/importlib/_bootstrap.py and https://github.com/python/cpython/blob/master/Lib/importlib/_bootstrap_external.py you will notice a bunch of comments near all the calls to load_module(). Those are the places that should be somehow triggering a DeprecationWarning.

I think there's a compatibility shim function which would need to raise an exception so that anyone who has implemented load_module() as the only way to handle loading get a warning (but I think that requires certain loaders to have appropriate support which hopefully they have already but someone needs to double-check). After that every implementation of load_module() should have a warning.

----------

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


More information about the Python-bugs-list mailing list