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

Delta Between Two Patch Sets: Lib/importlib/_bootstrap.py

Issue 18864: Implementation for PEP 451 (importlib.machinery.ModuleSpec)
Left Patch Set: Created 5 years, 10 months ago
Right Patch Set: Created 5 years, 9 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:
Right: Side by side diff | Download
« no previous file with change/comment | « Doc/library/importlib.rst ('k') | Lib/test/test_importlib/test_spec.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 """The name of the module's parent.""" 834 """The name of the module's parent."""
835 if self.submodule_search_locations is None: 835 if self.submodule_search_locations is None:
836 return self.name.rpartition('.')[0] 836 return self.name.rpartition('.')[0]
837 else: 837 else:
838 return self.name 838 return self.name
839 839
840 @property 840 @property
841 def has_location(self): 841 def has_location(self):
842 return self._set_fileattr 842 return self._set_fileattr
843 843
844 @has_location.setter
845 def has_location(self, value):
846 self._set_fileattr = bool(value)
847
844 848
845 def spec_from_loader(name, loader, *, origin=None, is_package=None): 849 def spec_from_loader(name, loader, *, origin=None, is_package=None):
846 """Return a module spec based on various loader methods.""" 850 """Return a module spec based on various loader methods."""
847 if hasattr(loader, 'get_filename'): 851 if hasattr(loader, 'get_filename'):
848 if is_package is None: 852 if is_package is None:
849 return spec_from_file_location(name, loader=loader) 853 return spec_from_file_location(name, loader=loader)
850 search = [] if is_package else None 854 search = [] if is_package else None
851 return spec_from_file_location(name, loader=loader, 855 return spec_from_file_location(name, loader=loader,
852 submodule_search_locations=search) 856 submodule_search_locations=search)
853 857
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 def _install(sys_module, _imp_module): 2375 def _install(sys_module, _imp_module):
2372 """Install importlib as the implementation of import.""" 2376 """Install importlib as the implementation of import."""
2373 _setup(sys_module, _imp_module) 2377 _setup(sys_module, _imp_module)
2374 supported_loaders = _get_supported_file_loaders() 2378 supported_loaders = _get_supported_file_loaders()
2375 sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)]) 2379 sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)])
2376 sys.meta_path.append(BuiltinImporter) 2380 sys.meta_path.append(BuiltinImporter)
2377 sys.meta_path.append(FrozenImporter) 2381 sys.meta_path.append(FrozenImporter)
2378 if _os.__name__ == 'nt': 2382 if _os.__name__ == 'nt':
2379 sys.meta_path.append(WindowsRegistryFinder) 2383 sys.meta_path.append(WindowsRegistryFinder)
2380 sys.meta_path.append(PathFinder) 2384 sys.meta_path.append(PathFinder)
LEFTRIGHT

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