Fix tracking of imported modules

__import__(name, ..., fromlist, ...) always returns the top-level package if `import x.y.z` is used (here `x`), and the module given by `name` if `from x.y.z import a` is used, here `x.y.z`. Differentiating between these two cases can be done by looking at the `fromlist` argument. By not tracking modules correctly, plugin unloading/reloading was broken if a module hierarchy within a plugin was used and `from` was not exclusively used.
This commit is contained in:
Maik Riechert 2018-01-18 23:26:36 +00:00 committed by GitHub
parent bc1bfd3406
commit 19592dc8d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -664,7 +664,7 @@ def _import(name, globals={}, locals={}, fromlist=[], level=None):
mod = _builtin_import(name, globals, locals, fromlist, level)
if mod and '__file__' in mod.__dict__:
module_name = mod.__name__
module_name = mod.__name__ if fromlist else name
package_name = module_name.split('.')[0]
# check whether the module belongs to one of our plugins
if package_name in available_plugins: