title: pycryptodome: Object type <class 'str'> cannot be passed to C code - virtual environment
body: <p>I am trying to run the following snippet in python2.7 (<code>key</code> variable has been already set):</p>
  
  <pre><code>import binascii
  from Crypto.Cipher import AES
  
  iv = binascii.unhexlify(u'd75b8c8b8c8bc1add8f8fcc1add8f8fc')
  AES.new(key, AES.MODE_CFB, iv) 
  </code></pre>
  
  <p>The following exception pops up:</p>
  
  <pre><code>Error: 
      raise TypeError("Object type %s cannot be passed to C code" % type(data))
  TypeError: Object type &lt;type 'unicode'&gt; cannot be passed to C code 
  </code></pre>
  
  <p>According to the <a href="https://docs.python.org/2.7/library/binascii.html#binascii.unhexlify" rel="nofollow noreferrer">binascii docs</a>:</p>
  
  <pre><code>Return the binary data represented by the hexadecimal string hexstr. This function is the inverse of b2a_hex(). hexstr must contain an even number of hexadecimal digits (which can be upper or lower case), otherwise a TypeError is raised.
  </code></pre>
  
  <p>And the <a href="https://pycryptodome.readthedocs.io/en/latest/src/cipher/aes.html?highlight=AES.new#Crypto.Cipher.AES.new" rel="nofollow noreferrer">pycryptodome docs</a>:</p>
  
  <pre><code>iv (bytes, bytearray, memoryview) – (Only applicable for MODE_CBC, MODE_CFB, MODE_OFB, and MODE_OPENPGP modes).
  
  The initialization vector to use for encryption or decryption.
  
  For MODE_CBC, MODE_CFB, and MODE_OFB it must be 16 bytes long.
  
  For MODE_OPENPGP mode only, it must be 16 bytes long for encryption and 18 bytes for decryption (in the latter case, it is actually the encrypted IV which was prefixed to the ciphertext).
  
  If not provided, a random byte string is generated (you must then read its value with the iv attribute).
  </code></pre>
  
  <p>The <code>iv</code> variable is of even length, so why is the TypeError raised?</p>