Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Side by Side Diff: Lib/importlib/_bootstrap.py

Issue 19413: Reload semantics changed unexpectedly in Python 3.3
Patch Set: Created 6 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/importlib/__init__.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Core implementation of import. 1 """Core implementation of import.
2 2
3 This module is NOT meant to be directly imported! It has been designed such 3 This module is NOT meant to be directly imported! It has been designed such
4 that it can be bootstrapped into Python as the implementation of import. As 4 that it can be bootstrapped into Python as the implementation of import. As
5 such it requires the injection of specific modules and attributes in order to 5 such it requires the injection of specific modules and attributes in order to
6 work. One should use importlib as the public-facing version of this module. 6 work. One should use importlib as the public-facing version of this module.
7 7
8 """ 8 """
9 # 9 #
10 # IMPORTANT: Whenever making changes to this module, be sure to run 10 # IMPORTANT: Whenever making changes to this module, be sure to run
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 if not sys.meta_path: 1511 if not sys.meta_path:
1512 _warnings.warn('sys.meta_path is empty', ImportWarning) 1512 _warnings.warn('sys.meta_path is empty', ImportWarning)
1513 for finder in sys.meta_path: 1513 for finder in sys.meta_path:
1514 with _ImportLockContext(): 1514 with _ImportLockContext():
1515 loader = finder.find_module(name, path) 1515 loader = finder.find_module(name, path)
1516 if loader is not None: 1516 if loader is not None:
1517 # The parent import may have already imported this module. 1517 # The parent import may have already imported this module.
1518 if name not in sys.modules: 1518 if name not in sys.modules:
1519 return loader 1519 return loader
1520 else: 1520 else:
1521 return sys.modules[name].__loader__ 1521 try:
1522 return sys.modules[name].__loader__
1523 except AttributeError:
1524 return loader
1522 else: 1525 else:
1523 return None 1526 return None
1524 1527
1525 1528
1526 def _sanity_check(name, package, level): 1529 def _sanity_check(name, package, level):
1527 """Verify arguments are "sane".""" 1530 """Verify arguments are "sane"."""
1528 if not isinstance(name, str): 1531 if not isinstance(name, str):
1529 raise TypeError('module name must be str, not {}'.format(type(name))) 1532 raise TypeError('module name must be str, not {}'.format(type(name)))
1530 if level < 0: 1533 if level < 0:
1531 raise ValueError('level must be >= 0') 1534 raise ValueError('level must be >= 0')
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 def _install(sys_module, _imp_module): 1802 def _install(sys_module, _imp_module):
1800 """Install importlib as the implementation of import.""" 1803 """Install importlib as the implementation of import."""
1801 _setup(sys_module, _imp_module) 1804 _setup(sys_module, _imp_module)
1802 supported_loaders = _get_supported_file_loaders() 1805 supported_loaders = _get_supported_file_loaders()
1803 sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)]) 1806 sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)])
1804 sys.meta_path.append(BuiltinImporter) 1807 sys.meta_path.append(BuiltinImporter)
1805 sys.meta_path.append(FrozenImporter) 1808 sys.meta_path.append(FrozenImporter)
1806 if _os.__name__ == 'nt': 1809 if _os.__name__ == 'nt':
1807 sys.meta_path.append(WindowsRegistryFinder) 1810 sys.meta_path.append(WindowsRegistryFinder)
1808 sys.meta_path.append(PathFinder) 1811 sys.meta_path.append(PathFinder)
OLDNEW
« no previous file with comments | « no previous file | Lib/importlib/__init__.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+