@@ -69,15 +69,15 @@ def _find_module(name, path=None):
6969 # Some special cases:
7070
7171 if spec .loader is importlib .machinery .BuiltinImporter :
72- return None , None , ("" , _C_BUILTIN )
72+ return None , None , ("" , "" , _C_BUILTIN )
7373
7474 if spec .loader is importlib .machinery .FrozenImporter :
75- return None , None , ("" , _PY_FROZEN )
75+ return None , None , ("" , "" , _PY_FROZEN )
7676
7777 file_path = spec .origin
7878
7979 if spec .loader .is_package (name ):
80- return None , os .path .dirname (file_path ), ("" , _PKG_DIRECTORY )
80+ return None , os .path .dirname (file_path ), ("" , "" , _PKG_DIRECTORY )
8181
8282 if isinstance (spec .loader , importlib .machinery .SourceFileLoader ):
8383 kind = _PY_SOURCE
@@ -89,12 +89,12 @@ def _find_module(name, path=None):
8989 kind = _PY_COMPILED
9090
9191 else : # Should never happen.
92- return None , None , ("" , _SEARCH_ERROR )
92+ return None , None , ("" , "" , _SEARCH_ERROR )
9393
9494 file = io .open_code (file_path )
9595 suffix = os .path .splitext (file_path )[- 1 ]
9696
97- return file , file_path , (suffix , kind )
97+ return file , file_path , (suffix , "rb" , kind )
9898
9999
100100class Module :
@@ -159,14 +159,14 @@ def msgout(self, *args):
159159 def run_script (self , pathname ):
160160 self .msg (2 , "run_script" , pathname )
161161 with io .open_code (pathname ) as fp :
162- stuff = ("" , _PY_SOURCE )
162+ stuff = ("" , "rb" , _PY_SOURCE )
163163 self .load_module ('__main__' , fp , pathname , stuff )
164164
165165 def load_file (self , pathname ):
166166 dir , name = os .path .split (pathname )
167167 name , ext = os .path .splitext (name )
168168 with io .open_code (pathname ) as fp :
169- stuff = (ext , _PY_SOURCE )
169+ stuff = (ext , "rb" , _PY_SOURCE )
170170 self .load_module (name , fp , pathname , stuff )
171171
172172 def import_hook (self , name , caller = None , fromlist = None , level = - 1 ):
@@ -320,6 +320,7 @@ def import_module(self, partname, fqname, parent):
320320 except ImportError :
321321 self .msgout (3 , "import_module ->" , None )
322322 return None
323+
323324 try :
324325 m = self .load_module (fqname , fp , pathname , stuff )
325326 finally :
@@ -331,7 +332,7 @@ def import_module(self, partname, fqname, parent):
331332 return m
332333
333334 def load_module (self , fqname , fp , pathname , file_info ):
334- suffix , type = file_info
335+ suffix , mode , type = file_info
335336 self .msgin (2 , "load_module" , fqname , fp and "fp" , pathname )
336337 if type == _PKG_DIRECTORY :
337338 m = self .load_package (fqname , pathname )
@@ -502,7 +503,7 @@ def find_module(self, name, path, parent=None):
502503
503504 if path is None :
504505 if name in sys .builtin_module_names :
505- return (None , None , ("" , _C_BUILTIN ))
506+ return (None , None , ("" , "" , _C_BUILTIN ))
506507
507508 path = self .path
508509
0 commit comments