def get_unicode_from_response(r):

    tried_encodings = []

    # Try charset from content-type
    encoding = get_encoding_from_headers(r.headers)

    if encoding:
        try:
            return unicode(r.content, encoding)
        except UnicodeError:
            tried_encodings.append(encoding)

    # Fall back:
    try:
        return unicode(r.content, encoding, errors='replace')
    except TypeError:
        return r.content
Regression test for https://github.com/astropy/astropy/pull/4514
dataset/ETHPy150Open bububa/pyTOP/pyTOP/packages/requests/utils.py/get_unicode_from_response--crossover with--dataset/ETHPy150Open spacetelescope/PyFITS/pyfits/tests/test_table.py/TestColumnFunctions.test_p_column_deepcopy