Skip to content

Commit

Permalink
[Backport release-3_4] Remove plugin module path when unloading (#9862)
Browse files Browse the repository at this point in the history
* Remove plugin module path  when unloading

    Unloading plugin must remove added module path
    in order to prevent wrong package import when reloading
  • Loading branch information
backporting[bot] authored and m-kuhn committed May 11, 2019
1 parent 90abfe2 commit 9a492b4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,16 @@ def _unloadPluginModules(packageName):
sys.modules[mod].qCleanupResources()
except:
pass

# try removing path
if hasattr(sys.modules[mod], '__path__'):
for path in sys.modules[mod].__path__:
try:
sys.path.remove(path)
except ValueError:
# Discard if path is not there
pass

# try to remove the module from python
try:
del sys.modules[mod]
Expand Down

0 comments on commit 9a492b4

Please sign in to comment.