Skip to content

Commit

Permalink
Fix tracking of imported modules
Browse files Browse the repository at this point in the history
__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.
  • Loading branch information
letmaik authored Jan 18, 2018
1 parent bc1bfd3 commit 19592dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 19592dc

Please sign in to comment.