Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes an error when unloading plugins
Custom utils._import was never called, because
builtins was correctly imported (even if it missed __import__)
and  _import was then monkey patched to builtins instead of __builtin__

Tested on python 2
  • Loading branch information
elpaso committed Mar 25, 2016
1 parent 8af5edc commit 2d3b813
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions python/utils.py
Expand Up @@ -581,13 +581,13 @@ def startServerPlugin(packageName):
#######################
# IMPORT wrapper

_uses_builtins = True
try:
import builtins

_builtin_import = builtins.__import__
except AttributeError:
_uses_builtins = False
import __builtin__

_builtin_import = __builtin__.__import__

_plugin_modules = {}
Expand Down Expand Up @@ -616,7 +616,8 @@ def _import(name, globals={}, locals={}, fromlist=[], level=None):

return mod

try:

if _uses_builtins:
builtins.__import__ = _import
except AttributeError:
else:
__builtin__.__import__ = _import

0 comments on commit 2d3b813

Please sign in to comment.