(self, filename)
Do our best to decode a Python source file correctly.
Do our best to decode a Python source file correctly.
Do our best to decode a Python source file correctly .
def _read_python_source(self, filename):
        """
        Do our best to decode a Python source file correctly.
        """
        try:
            f = open(filename, "rb")
        except OSError as err:
            self.log_error("Can't open %s: %s", filename, err)
            return None, None
        try:
            encoding = tokenize.detect_encoding(f.readline)[0]
        finally:
            f.close()
        with io.open(filename, "r", encoding=encoding, newline='') as f:
            return f.read(), encoding
def _read_python_source ( self , filename ) : try : f = open ( filename , "rb" ) except OSError as err : self . log_error ( "Can't open %s: %s" , filename , err ) return None , None try : encoding = tokenize . detect_encoding ( f . readline ) [ 0 ] finally : f . close ( ) with io . open ( filename , "r" , encoding = encoding , newline = '' ) as f : return f . read ( ) , encoding