Object type <class 'tuple'> cannot be passed to C code

so i want encrypt file using key what i was input. but there’s error message:

Object type <class ‘tuple’> cannot be passed to C code

i don;t know what is class tuple. but the error is code is:
aes = AES.new(key.encode('utf8'), AES.MODE_CTR, counter=ctr)

here’s the full code:

# AES supports multiple key sizes: 16 (AES128), 24 (AES192), or 32 (AES256).
key_bytes = 16
# Takes as input a 32-byte key and an arbitrary-length plaintext and returns a
# pair (iv, ciphtertext). "iv" stands for initialization vector.
def encrypt(key, testpass):
    assert len(key) == key_bytes
    # Choose a random, 16-byte IV.
    iv = Random.new().read(AES.block_size)

    # Convert the IV to a Python integer.
    iv_int = int(binascii.hexlify(iv), 16)

    # Create a new Counter object with IV = iv_int.
    ctr = Counter.new(AES.block_size * 8, initial_value=iv_int)

    # Create AES-CTR cipher.
    aes = AES.new(key.encode('utf8'), AES.MODE_CTR, counter=ctr)

    # Encrypt and return IV and ciphertext.
    ciphertext = aes.encrypt(testpass)
    return (iv, ciphertext)

From the error message, I’d check (either using the debugger or print statements) what the type is of all the variables being used here.

You haven’t specified what libraries you’re using, what versions of Python, etc, are being used, how this is being used, what you’re passing to it or the complete traceback, so it really isn’t possible for us to offer any concrete suggestions.

And a side note - how is this related to Django? This seems to be specifically a Python / 3rd party library issue.