This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients brett.cannon, docs@python, vstinner
Date 2021-03-18.10:19:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616062773.63.0.458155955758.issue43540@roundup.psfhosted.org>
In-reply-to
Content
The load_module() method of importlib loaders is deprecated which cause test failures in multiple projects.

It is not easy to guess how to replace it. Examples:

* pkg_resources fix adding create_module() and exec_module() methods: https://github.com/pypa/setuptools/commit/6ad2fb0b78d11e22672f56ef9d65d13ebd3475a9
* pkg_resources fix replacing importlib.load_module() function call (not loader methods) with importlib.import_module(): https://github.com/pypa/setuptools/commit/a54d9e6b30c6da0542698144d2ff149ae7cadc9a

Cython uses this code:

if sys.version_info[:2] < (3, 3):
    import imp
    def load_dynamic(name, module_path):
        return imp.load_dynamic(name, module_path)
else:
    from importlib.machinery import ExtensionFileLoader
    def load_dynamic(name, module_path):
        return ExtensionFileLoader(name, module_path).load_module()

Fixed Cython code:

if sys.version_info < (3, 5):
    import imp
    def load_dynamic(name, module_path):
        return imp.load_dynamic(name, module_path)
else:
    import importlib.util as _importlib_util
    def load_dynamic(name, module_path):
        spec = _importlib_util.spec_from_file_location(name, module_path)
        module = _importlib_util.module_from_spec(spec)
        # sys.modules[name] = module
        spec.loader.exec_module(module)
        return module
History
Date User Action Args
2021-03-18 10:19:33vstinnersetrecipients: + vstinner, brett.cannon, docs@python
2021-03-18 10:19:33vstinnersetmessageid: <1616062773.63.0.458155955758.issue43540@roundup.psfhosted.org>
2021-03-18 10:19:33vstinnerlinkissue43540 messages
2021-03-18 10:19:33vstinnercreate