##// END OF EJS Templates
Don't import mirror for `__spec__` until requested...
Min RK -
Show More
@@ -3,7 +3,6
3 # Copyright (c) IPython Development Team.
3 # Copyright (c) IPython Development Team.
4 # Distributed under the terms of the Modified BSD License.
4 # Distributed under the terms of the Modified BSD License.
5
5
6 import sys
7 import types
6 import types
8
7
9 class ShimModule(types.ModuleType):
8 class ShimModule(types.ModuleType):
@@ -11,8 +10,11 class ShimModule(types.ModuleType):
11 def __init__(self, *args, **kwargs):
10 def __init__(self, *args, **kwargs):
12 self._mirror = kwargs.pop("mirror")
11 self._mirror = kwargs.pop("mirror")
13 super(ShimModule, self).__init__(*args, **kwargs)
12 super(ShimModule, self).__init__(*args, **kwargs)
14 if sys.version_info >= (3,4):
13
15 self.__spec__ = __import__(self._mirror).__spec__
14 @property
15 def __spec__(self):
16 """Don't produce __spec__ until requested"""
17 return __import__(self._mirror).__spec__
16
18
17 def __getattr__(self, key):
19 def __getattr__(self, key):
18 # Use the equivalent of import_item(name), see below
20 # Use the equivalent of import_item(name), see below
General Comments 0
You need to be logged in to leave comments. Login now