##// END OF EJS Templates
Avoid reloading builtin `types` module....
Matthias Bussonnier -
Show More
@@ -39,6 +39,7 b' import sys'
39
39
40 from types import ModuleType
40 from types import ModuleType
41 from warnings import warn
41 from warnings import warn
42 import types
42
43
43 original_import = builtin_mod.__import__
44 original_import = builtin_mod.__import__
44
45
@@ -162,6 +163,7 b' def load_next(mod, altmod, name, buf):'
162
163
163 return result, next, buf
164 return result, next, buf
164
165
166
165 # Need to keep track of what we've already reloaded to prevent cyclic evil
167 # Need to keep track of what we've already reloaded to prevent cyclic evil
166 found_now = {}
168 found_now = {}
167
169
@@ -269,6 +271,12 b' modules_reloading = {}'
269
271
270 def deep_reload_hook(m):
272 def deep_reload_hook(m):
271 """Replacement for reload()."""
273 """Replacement for reload()."""
274 # Hardcode this one as it would raise a NotImplemeentedError from the
275 # bowels of Python and screw up the import machinery after.
276 # unlike other imports the `exclude` list aleady in place is not enough.
277
278 if m is types:
279 return m
272 if not isinstance(m, ModuleType):
280 if not isinstance(m, ModuleType):
273 raise TypeError("reload() argument must be module")
281 raise TypeError("reload() argument must be module")
274
282
@@ -319,7 +327,7 b' def deep_reload_hook(m):'
319 return newm
327 return newm
320
328
321 # Save the original hooks
329 # Save the original hooks
322 original_reload = imp.reload # Python 3
330 original_reload = imp.reload
323
331
324 # Replacement for reload()
332 # Replacement for reload()
325 def reload(module, exclude=('sys', 'os.path', 'builtins', '__main__',
333 def reload(module, exclude=('sys', 'os.path', 'builtins', '__main__',
General Comments 0
You need to be logged in to leave comments. Login now