[docs] [issue16421] importlib.machinery.ExtensionFileLoader cannot load several modules from the same shared object
report at bugs.python.org
Tue Nov 6 15:42:53 CET 2012
New submission from Václav Šmilauer:
This issue was split off issue16194 (I am not copying the whole discussion here). It was suggested a new issue is opened for Python3, where a proper fix can be done.
Python internally caches dynamically loaded modules, but the cache is based on the filename only. If one file contains several modules, only the first of them is imported and initialized properly. This interface was previously exposed via imp.load_dynamic, the same codepath is used by importlib.machinery.ExtensionFileLoader now.
A solution is to cache by the (filename, modulename) tuple, which avoids any ambiguity.
I am attaching a simple patch for that, agains current hg tip (80272:ec00f8570c55), and tested with the scripot attached to issue16194.
I have not modified the test suite, I am not sure whether testing compiled modules is actually supported (did not see any compiled files in there), I will be glad for help.
components: Extension Modules
nosy: Arfrever, amaury.forgeotdarc, brett.cannon, docs at python, eudoxos, ncoghlan, r.david.murray
title: importlib.machinery.ExtensionFileLoader cannot load several modules from the same shared object
versions: Python 3.5
Added file: http://bugs.python.org/file27909/many-modules-in-one-so_1.diff
Python tracker <report at bugs.python.org>
More information about the docs