cffi_utils/py2to3.py
def fromBytes(x):
    '''
    x-->unicode string | bytearray | bytes
    Returns-->unicode string, with encoding=latin1
    '''
    if isinstance(x, unicode):
        return x
    if isinstance(x, bytearray):
        x = bytes(x)
    elif isinstance(x, bytes):
        pass
    else:
        return x  # unchanged (int etc)
    return decode(x, DEF_ENCODING)
def fromBytes(x):
    '''
    x-->unicode string | bytearray | bytes
    Returns-->unicode string, with encoding=latin1
    '''
    if isinstance(x, unicode):
        return x
    if isinstance(x, bytearray):
        x = bytes(x)
    elif isinstance(x, bytes):
        pass
    else:
        return x  # unchanged (int etc)
    return decode(x, DEF_ENCODING)
x-->unicode string | bytearray | bytes
    Returns-->unicode string, with encoding=latin1