LEFT | RIGHT |
(no file at all) | |
1 """Core implementation of path-based import. | 1 """Core implementation of path-based 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 # Python 3.6a1 3370 (16 bit wordcode) | 232 # Python 3.6a1 3370 (16 bit wordcode) |
233 # Python 3.6a1 3371 (add BUILD_CONST_KEY_MAP opcode #27140) | 233 # Python 3.6a1 3371 (add BUILD_CONST_KEY_MAP opcode #27140) |
234 # Python 3.6a1 3372 (MAKE_FUNCTION simplification, remove MAKE_CLOSURE | 234 # Python 3.6a1 3372 (MAKE_FUNCTION simplification, remove MAKE_CLOSURE |
235 # #27095) | 235 # #27095) |
236 # Python 3.6b1 3373 (add BUILD_STRING opcode #27078) | 236 # Python 3.6b1 3373 (add BUILD_STRING opcode #27078) |
237 # Python 3.6b1 3375 (add SETUP_ANNOTATIONS and STORE_ANNOTATION opcodes | 237 # Python 3.6b1 3375 (add SETUP_ANNOTATIONS and STORE_ANNOTATION opcodes |
238 # #27985) | 238 # #27985) |
239 # Python 3.6b1 3376 (simplify CALL_FUNCTIONs & BUILD_MAP_UNPACK_WITH_CALL) | 239 # Python 3.6b1 3376 (simplify CALL_FUNCTIONs & BUILD_MAP_UNPACK_WITH_CALL) |
240 # Python 3.6b1 3377 (set __class__ cell from type.__new__ #23722) | 240 # Python 3.6b1 3377 (set __class__ cell from type.__new__ #23722) |
241 # Python 3.6b2 3378 (add BUILD_TUPLE_UNPACK_WITH_CALL #28257) | 241 # Python 3.6b2 3378 (add BUILD_TUPLE_UNPACK_WITH_CALL #28257) |
| 242 # Python 3.6rc1 3379 (more thorough __class__ validation #23722) |
242 # | 243 # |
243 # MAGIC must change whenever the bytecode emitted by the compiler may no | 244 # MAGIC must change whenever the bytecode emitted by the compiler may no |
244 # longer be understood by older implementations of the eval loop (usually | 245 # longer be understood by older implementations of the eval loop (usually |
245 # due to the addition of new opcodes). | 246 # due to the addition of new opcodes). |
246 # | 247 # |
247 # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array | 248 # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array |
248 # in PC/launcher.c must also be updated. | 249 # in PC/launcher.c must also be updated. |
249 | 250 |
250 MAGIC_NUMBER = (3378).to_bytes(2, 'little') + b'\r\n' | 251 MAGIC_NUMBER = (3379).to_bytes(2, 'little') + b'\r\n' |
251 _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c | 252 _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c |
252 | 253 |
253 _PYCACHE = '__pycache__' | 254 _PYCACHE = '__pycache__' |
254 _OPT = 'opt-' | 255 _OPT = 'opt-' |
255 | 256 |
256 SOURCE_SUFFIXES = ['.py'] # _setup() adds .pyw as needed. | 257 SOURCE_SUFFIXES = ['.py'] # _setup() adds .pyw as needed. |
257 | 258 |
258 BYTECODE_SUFFIXES = ['.pyc'] | 259 BYTECODE_SUFFIXES = ['.pyc'] |
259 # Deprecated. | 260 # Deprecated. |
260 DEBUG_BYTECODE_SUFFIXES = OPTIMIZED_BYTECODE_SUFFIXES = BYTECODE_SUFFIXES | 261 DEBUG_BYTECODE_SUFFIXES = OPTIMIZED_BYTECODE_SUFFIXES = BYTECODE_SUFFIXES |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 | 1436 |
1436 | 1437 |
1437 def _install(_bootstrap_module): | 1438 def _install(_bootstrap_module): |
1438 """Install the path-based import components.""" | 1439 """Install the path-based import components.""" |
1439 _setup(_bootstrap_module) | 1440 _setup(_bootstrap_module) |
1440 supported_loaders = _get_supported_file_loaders() | 1441 supported_loaders = _get_supported_file_loaders() |
1441 sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)]) | 1442 sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)]) |
1442 if _os.__name__ == 'nt': | 1443 if _os.__name__ == 'nt': |
1443 sys.meta_path.append(WindowsRegistryFinder) | 1444 sys.meta_path.append(WindowsRegistryFinder) |
1444 sys.meta_path.append(PathFinder) | 1445 sys.meta_path.append(PathFinder) |
LEFT | RIGHT |