[issue24748] Change of behavior for importlib between 3.4 and 3.5 with DLL loading

Etienne Fortin report at bugs.python.org
Thu Jul 30 15:45:35 CEST 2015


Etienne Fortin added the comment:

I replaced:
        import importlib.machinery
        loader = importlib.machinery.ExtensionFileLoader(name, path)
        return loader.load_module()

With:
    import importlib.machinery
    loader = importlib.machinery.ExtensionFileLoader(modname, filename)
    spec = importlib.machinery.ModuleSpec(
            name = modname,
            loader = loader,
            origin = filename,
            loader_state = 1234,
            is_package = False,
        )
    mod = loader.create_module(spec)
    loader.exec_module(mod)

And it now works as advertised. Since load_module() is flagged as Deprecated, I believe no correction is necessary as the preffered way to load a module, with exec_module(), is working. 

I will do some more tests to be sure it's the case.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24748>
_______________________________________


More information about the Python-bugs-list mailing list