Show More
@@ -78,10 +78,10 b' class _demandmod(object):' | |||||
78 | self._load() |
|
78 | self._load() | |
79 | setattr(self._module, attr, val) |
|
79 | setattr(self._module, attr, val) | |
80 |
|
80 | |||
81 |
def _demandimport(name, globals=None, locals=None, fromlist=None, level= |
|
81 | def _demandimport(name, globals=None, locals=None, fromlist=None, level=-1): | |
82 | if not locals or name in ignore or fromlist == ('*',): |
|
82 | if not locals or name in ignore or fromlist == ('*',): | |
83 | # these cases we can't really delay |
|
83 | # these cases we can't really delay | |
84 |
if level |
|
84 | if level == -1: | |
85 | return _origimport(name, globals, locals, fromlist) |
|
85 | return _origimport(name, globals, locals, fromlist) | |
86 | else: |
|
86 | else: | |
87 | return _origimport(name, globals, locals, fromlist, level) |
|
87 | return _origimport(name, globals, locals, fromlist, level) | |
@@ -91,7 +91,10 b' def _demandimport(name, globals=None, lo' | |||||
91 | base, rest = name.split('.', 1) |
|
91 | base, rest = name.split('.', 1) | |
92 | # email.__init__ loading email.mime |
|
92 | # email.__init__ loading email.mime | |
93 | if globals and globals.get('__name__', None) == base: |
|
93 | if globals and globals.get('__name__', None) == base: | |
94 | return _origimport(name, globals, locals, fromlist) |
|
94 | if level != -1: | |
|
95 | return _origimport(name, globals, locals, fromlist, level) | |||
|
96 | else: | |||
|
97 | return _origimport(name, globals, locals, fromlist) | |||
95 | # if a is already demand-loaded, add b to its submodule list |
|
98 | # if a is already demand-loaded, add b to its submodule list | |
96 | if base in locals: |
|
99 | if base in locals: | |
97 | if isinstance(locals[base], _demandmod): |
|
100 | if isinstance(locals[base], _demandmod): | |
@@ -99,7 +102,7 b' def _demandimport(name, globals=None, lo' | |||||
99 | return locals[base] |
|
102 | return locals[base] | |
100 | return _demandmod(name, globals, locals) |
|
103 | return _demandmod(name, globals, locals) | |
101 | else: |
|
104 | else: | |
102 |
if level |
|
105 | if level != -1: | |
103 | # from . import b,c,d or from .a import b,c,d |
|
106 | # from . import b,c,d or from .a import b,c,d | |
104 | return _origimport(name, globals, locals, fromlist, level) |
|
107 | return _origimport(name, globals, locals, fromlist, level) | |
105 | # from a import b,c,d |
|
108 | # from a import b,c,d |
General Comments 0
You need to be logged in to leave comments.
Login now