'Do our best to decode a Python source file correctly.'

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 _open_with_encoding(filename, 'r', encoding=encoding) as f:
        return (_from_system_newlines(f.read()), encoding)
