ImportManager.py (cheetah3-3.2.3) | : | ImportManager.py (cheetah3-3.2.4) | ||
---|---|---|---|---|
skipping to change at line 24 | skipping to change at line 24 | |||
- standardized the variable naming scheme | - standardized the variable naming scheme | |||
- reorganized the code layout to enhance readability | - reorganized the code layout to enhance readability | |||
""" | """ | |||
import marshal | import marshal | |||
import py_compile | import py_compile | |||
import sys | import sys | |||
from Cheetah.compat import PY2, string_type, new_module, get_suffixes, \ | from Cheetah.compat import PY2, string_type, new_module, get_suffixes, \ | |||
load_module_from_file | load_module_from_file, RecursionError | |||
if PY2: | if PY2: | |||
import imp | import imp | |||
else: | else: | |||
import importlib.machinery | import importlib.machinery | |||
_installed = False | _installed = False | |||
# _globalOwnerTypes is defined at the bottom of this file | # _globalOwnerTypes is defined at the bottom of this file | |||
_os_stat = _os_path_join = _os_getcwd = _os_path_dirname = None | _os_stat = _os_path_join = _os_getcwd = _os_path_dirname = None | |||
skipping to change at line 507 | skipping to change at line 507 | |||
subimporter = PathImportDirector(parent.__path__) | subimporter = PathImportDirector(parent.__path__) | |||
importfunc = parent.__importsub__ = subimporter.getmod | importfunc = parent.__importsub__ = subimporter.getmod | |||
mod = importfunc(nm) | mod = importfunc(nm) | |||
if mod: | if mod: | |||
setattr(parent, nm, mod) | setattr(parent, nm, mod) | |||
else: | else: | |||
return None | return None | |||
else: | else: | |||
# now we're dealing with an absolute import | # now we're dealing with an absolute import | |||
for director in self.metapath: | for director in self.metapath: | |||
mod = director.getmod(nm) | try: | |||
mod = director.getmod(nm) | ||||
except RecursionError: | ||||
mod = __oldimport__(nm) # noqa: F821 undefined name | ||||
if mod: | if mod: | |||
break | break | |||
if mod: | if mod: | |||
mod.__name__ = fqname | mod.__name__ = fqname | |||
sys.modules[fqname] = mod | sys.modules[fqname] = mod | |||
if hasattr(mod, '__co__'): | if hasattr(mod, '__co__'): | |||
co = mod.__co__ | co = mod.__co__ | |||
del mod.__co__ | del mod.__co__ | |||
exec(co, mod.__dict__) | exec(co, mod.__dict__) | |||
if fqname == 'thread' and not self.threaded: | if fqname == 'thread' and not self.threaded: | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 5 lines changed or added |