Skip to content

Commit 2d3b813

Browse files
committedMar 25, 2016
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
1 parent 8af5edc commit 2d3b813

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎python/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,13 @@ def startServerPlugin(packageName):
581581
#######################
582582
# IMPORT wrapper
583583

584+
_uses_builtins = True
584585
try:
585586
import builtins
586-
587587
_builtin_import = builtins.__import__
588588
except AttributeError:
589+
_uses_builtins = False
589590
import __builtin__
590-
591591
_builtin_import = __builtin__.__import__
592592

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

617617
return mod
618618

619-
try:
619+
620+
if _uses_builtins:
620621
builtins.__import__ = _import
621-
except AttributeError:
622+
else:
622623
__builtin__.__import__ = _import

0 commit comments

Comments
 (0)
Please sign in to comment.