title: UnicodeDecodeError: 'utf-16-le' codec can't decode bytes in position 10-11: illegal encoding
body: <p>I am getting</p>
  <pre><code>  File &quot;/opt/rh/rh-python36/root/usr/lib64/python3.6/encodings/utf_16_le.py&quot;, line 16, in decode
      return codecs.utf_16_le_decode(input, errors, True)
  UnicodeDecodeError: 'utf-16-le' codec can't decode bytes in position 10-11: illegal encoding
  </code></pre>
  <p>and sometime</p>
  <pre><code> curr.execute(sql)
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 4: unexpected end of data
  </code></pre>
  <p>connecting to
  DB2 database using <code>iAccess Client Solutions</code> driver</p>
  <ul>
  <li><p>python 3.6</p>
  </li>
  <li><p>pyodbc 4.0.30</p>
  </li>
  </ul>
  <p>got a valid connection object, so connection is successful, however parsing the SQL string is having problem, not sure why pyodbc is not passing the SQL string to the driver, do not have any special character/non unicode character in the SQL.</p>
  <p>Also, the same code works fine in python3.4/pyodbc 3.0.7 with same Db2 iAccess driver version.</p>
  <p>When captured <code>mtrace</code> output it shows below where after <code>curr execute</code> call <code>codecs.utf_16_le_decode</code> gets called, not sure why. Is this default behavior in python 3.6?</p>
  <pre><code>test_as400_36.py(41): curr.execute(sql)
   --- modulename: utf_16_le, funcname: decode
  utf_16_le.py(16):     return codecs.utf_16_le_decode(input, errors, True)
   --- modulename: trace, funcname: _unsettrace
  trace.py(77):         sys.settrace(None)
  
   
  &lt;pyodbc.Connection object at 0x7f3b3e8068a0&gt;
  </code></pre>
  <p>below the code.</p>
  <pre><code>import sys
  import pyodbc
  import csv
  import logging
  
  logging.basicConfig(level='INFO', format='[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s')
  logger = logging.getLogger(__name__)
  
  pyodbc.pooling = False
  print(&quot;pyodbc version &quot; + pyodbc.version)
  
  cnxn=pyodbc.connect(r'DSN={};UID={};PWD={};'.format(&quot;DSN1&quot;,&quot;User1&quot;,&quot;passwd&quot;))
  
  print(cnxn)
  
  curr=cnxn.cursor()
  
  sql='''select
  FXLCCN
  from AILLIB.annpymtK
  '''
  
  curr.execute(sql)
  
  
  arraysize=500000
  logging.get_logger()
  rows_fetched=0
  
  while True:
              results = curr.fetchmany(arraysize)
              cnt_rows_fetched = len(results)
              logger.debug('%s Rows Fetched', cnt_rows_fetched)
              rows_fetched += cnt_rows_fetched
              logger.info('%s Total Rows Fetched', rows_fetched)
              if not results:
                  curr.close()
                  break
  
  </code></pre>