2626_CASE_INSENSITIVE_PLATFORMS = (_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY
2727 + _CASE_INSENSITIVE_PLATFORMS_STR_KEY )
2828
29+ _unspecified = object () # ironpython: default value for dict.get
2930
3031def _make_relax_case ():
3132 if sys .platform .startswith (_CASE_INSENSITIVE_PLATFORMS ):
@@ -358,18 +359,6 @@ def _get_sourcefile(bytecode_path):
358359 return source_path if _path_isfile (source_path ) else bytecode_path
359360
360361
361- def _get_cached (filename ):
362- if filename .endswith (tuple (SOURCE_SUFFIXES )):
363- try :
364- return cache_from_source (filename )
365- except NotImplementedError :
366- pass
367- elif filename .endswith (tuple (BYTECODE_SUFFIXES )):
368- return filename
369- else :
370- return None
371-
372-
373362def _calc_mode (path ):
374363 """Calculate the mode permissions for a bytecode file."""
375364 try :
@@ -749,46 +738,9 @@ def get_code(self, fullname):
749738 """
750739 source_path = self .get_filename (fullname )
751740 source_mtime = None
752- try :
753- bytecode_path = cache_from_source (source_path )
754- except NotImplementedError :
755- bytecode_path = None
756- else :
757- try :
758- st = self .path_stats (source_path )
759- except IOError :
760- pass
761- else :
762- source_mtime = int (st ['mtime' ])
763- try :
764- data = self .get_data (bytecode_path )
765- except OSError :
766- pass
767- else :
768- try :
769- bytes_data = _validate_bytecode_header (data ,
770- source_stats = st , name = fullname ,
771- path = bytecode_path )
772- except (ImportError , EOFError ):
773- pass
774- else :
775- _bootstrap ._verbose_message ('{} matches {}' , bytecode_path ,
776- source_path )
777- return _compile_bytecode (bytes_data , name = fullname ,
778- bytecode_path = bytecode_path ,
779- source_path = source_path )
780741 source_bytes = self .get_data (source_path )
781742 code_object = self .source_to_code (source_bytes , source_path )
782743 _bootstrap ._verbose_message ('code object from {}' , source_path )
783- if (not sys .dont_write_bytecode and bytecode_path is not None and
784- source_mtime is not None ):
785- data = _code_to_bytecode (code_object , source_mtime ,
786- len (source_bytes ))
787- try :
788- self ._cache_bytecode (source_path , bytecode_path , data )
789- _bootstrap ._verbose_message ('wrote {!r}' , bytecode_path )
790- except NotImplementedError :
791- pass
792744 return code_object
793745
794746
@@ -1092,9 +1044,9 @@ def _path_importer_cache(cls, path):
10921044 # Don't cache the failure as the cwd can easily change to
10931045 # a valid directory later on.
10941046 return None
1095- try :
1096- finder = sys .path_importer_cache [ path ]
1097- except KeyError :
1047+ # ironpython: optimization to avoid KeyError exception
1048+ finder = sys .path_importer_cache . get ( path , _unspecified )
1049+ if finder is _unspecified :
10981050 finder = cls ._path_hooks (path )
10991051 sys .path_importer_cache [path ] = finder
11001052 return finder
@@ -1361,10 +1313,8 @@ def _get_supported_file_loaders():
13611313
13621314 Each item is a tuple (loader, suffixes).
13631315 """
1364- extensions = ExtensionFileLoader , _imp .extension_suffixes ()
13651316 source = SourceFileLoader , SOURCE_SUFFIXES
1366- bytecode = SourcelessFileLoader , BYTECODE_SUFFIXES
1367- return [extensions , source , bytecode ]
1317+ return [source ]
13681318
13691319
13701320def _setup (_bootstrap_module ):
@@ -1390,6 +1340,7 @@ def _setup(_bootstrap_module):
13901340
13911341 # Directly load the os module (needed during bootstrap).
13921342 os_details = ('posix' , ['/' ]), ('nt' , ['\\ ' , '/' ])
1343+ if sys .platform == 'win32' : os_details = reversed (os_details ) # ironpython: optimization to avoid ImportError exception
13931344 for builtin_os , path_separators in os_details :
13941345 # Assumption made in _path_join()
13951346 assert all (len (sep ) == 1 for sep in path_separators )
@@ -1421,18 +1372,9 @@ def _setup(_bootstrap_module):
14211372 weakref_module = _bootstrap ._builtin_from_name ('_weakref' )
14221373 setattr (self_module , '_weakref' , weakref_module )
14231374
1424- # Directly load the winreg module (needed during bootstrap).
1425- if builtin_os == 'nt' :
1426- winreg_module = _bootstrap ._builtin_from_name ('winreg' )
1427- setattr (self_module , '_winreg' , winreg_module )
1428-
14291375 # Constants
14301376 setattr (self_module , '_relax_case' , _make_relax_case ())
14311377 EXTENSION_SUFFIXES .extend (_imp .extension_suffixes ())
1432- if builtin_os == 'nt' :
1433- SOURCE_SUFFIXES .append ('.pyw' )
1434- if '_d.pyd' in EXTENSION_SUFFIXES :
1435- WindowsRegistryFinder .DEBUG_BUILD = True
14361378
14371379
14381380def _install (_bootstrap_module ):
0 commit comments