def _convertToBytes(self, data):
    if (type(data) is bytearray):
        return bytes(data)
    if (type(data) is memoryview):
        return data.tobytes()
    return data
def _convertToBytes(self, data):
    if (type(data) is bytearray):
        return bytes(data)
    if (type(data) is memoryview):
        return data.tobytes()
    return data