Bug #71482 error Incorrect arguments when nation symbols used on pyton 3.3
Submitted: 26 Jan 2014 16:58 Modified: 28 Mar 2014 17:07
Reporter: Dmitry Chepel Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:1.1.4 OS:Any (founded on windows but i'm sure that it will occured anywhere)
Assigned to: CPU Architecture:Any
Tags: connector, cursor, internationalization, prepared, python 3

[26 Jan 2014 16:58] Dmitry Chepel
Description:
error occured when national symbols used on pyton 3.2 connector

  File "C:\A\devel\Python33\lib\site-packages\mysql\connector\cursor.py", line 1047, in execute       
    parameters=self._prepared['parameters'])                                                          
  File "C:\A\devel\Python33\lib\site-packages\mysql\connector\connection.py", line 1407, in cmd_stmt_e
    result = self._handle_binary_result(packet)                                                       
  File "C:\A\devel\Python33\lib\site-packages\mysql\connector\connection.py", line 1347, in _handle_bi
    raise errors.get_exception(packet)                                                                
mysql.connector.errors.ProgrammingError: 1210 (HY000): Incorrect arguments to mysqld_stmt_execute     

How to repeat:
config = dict(user='root', host='localhost', database='opds', charset='utf8', use_unicode=True)
cnx = mysql.connector.connect(**config)

c = cnx.cursor(prepared = True)

stmt = "insert into books (id, title_idx, title, filename, serie_id, serie_no, size) values(?, ?, ?, ?, ?, ?, ?)"
v1 = (2, 'a2', 'aaaаф natinal symbols there', 'f1', -1, 2, 3)

Suggested fix:

protocol.py:577 
                   v = value.encode('utf8')
                    values.append(
                        utils.intstore(len(v)) + v)

protocol.py:577
                    values.append(
                        utils.intstore(len(value)) + value.encode('utf8'))
[28 Mar 2014 17:07] Paul DuBois
Noted in 1.1.7 changelog.

In prepared statements, Unicode arguments in Python v2 and bytes
arguments in Python v3 were causing errors, as were the symbols of
character sets other than utf8 or ascii.